2016-04-07 10 views
1

FTPサーバーにファイルをアップロードする際に問題があります。 私のコンピュータ(127.0.0.1)でFileZillaサーバーを実行すると、イメージファイルが正常にアップロードされます。しかし、同じネットワーク内の別のコンピュータでFileZillaサーバーを実行します(10.0.1.25)。私はこのコンピュータ上でディレクトリを作成することができますが、私のユーザはこのコンピュータを完全に制御できますが、イメージファイルをアップロードすることはできません。ローカルネットワーク上のFTPファイルのアップロードC#

public bool Upload(Stream srcStream, string dstFilePath) 
    { 
     Create FtpWebRequest object from the Uri provided 
     FtpWebRequest reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(serverUri + dstFilePath)); 
     reqFTP.Credentials = credential; 
     reqFTP.Method = WebRequestMethods.Ftp.UploadFile; 
     reqFTP.UseBinary = true; 
     reqFTP.Proxy = null; 
     reqFTP.UsePassive = false; 
     reqFTP.KeepAlive = false; 
     reqFTP.ContentLength = srcStream.Length; 
     byte[] buff = new byte[UPLOAD_DOWNLOAD_BUFFER_SIZE]; 
     int contentLen; 

     // Stream to which the file to be upload is written 

      using (Stream dstStream = reqFTP.GetRequestStream()) 
      { 
       // Read from the file stream 2kb at a time 
       contentLen = srcStream.Read(buff, 0, UPLOAD_DOWNLOAD_BUFFER_SIZE); 

       // Till Stream content ends 
       while (contentLen != 0) 
       { 
        // Write Content from the file stream to the FTP Upload Stream 
        dstStream.Write(buff, 0, contentLen); 
        contentLen = srcStream.Read(buff, 0, UPLOAD_DOWNLOAD_BUFFER_SIZE); 
       } 

       dstStream.Close(); 
      } 
     } 

     // Get the response to the upload request. 
     bool ret; 
     FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); 
     // ret = (response.StatusCode == FtpStatusCode.ClosingData); // 
     response.Close(); 

     ret = (GetFileSize(dstFilePath) == srcStream.Length); 

     return ret; 
    } 

iは真reqFTP.UsePassive =、ライン9を変更し、サーバは(227の入力パッシブモード(H1、H2、H3、H4、P1、P2))を返します。今すぐ戻ります(500)構文エラー、コマンドが認識されません。問題は何でしょうか? ありがとう

+0

ウイルス対策プログラムを停止しました。その後、ファイルが転送されます。 –

答えて

0

アンチウィルスが実行されている間にイメージファイルをアップロードできます。しかし、私は私のコードブロックを使用してそれを試してみる。ポートエラーメッセージを返します。ウイルス対策が終了すると、すべて正常に動作します。

関連する問題