0

我正在做将文件从一台服务器上传到另一台服务器的代码,以下是我的代码:

      string CompleteDPath = "ftp://ExampleURL/photos/";
        string UName = "USerName";
        string PWD = "Password";
        WebRequest reqObj = WebRequest.Create(CompleteDPath + fileName);
        reqObj.Method = WebRequestMethods.Ftp.UploadFile;
        reqObj.Credentials = new NetworkCredential(UName, PWD);
        FileStream streamObj = System.IO.File.OpenRead(Server.MapPath(path));
        byte[] buffer = new byte[streamObj.Length + 1];
        streamObj.Read(buffer, 0, buffer.Length);
        streamObj.Close();
        streamObj = null;
        reqObj.GetRequestStream().Write(buffer, 0, buffer.Length);
        reqObj = null;

但第一次它工作正常,但下一次它抛出错误如下:远程服务器返回错误:227进入被动模式()

你能告诉我这有什么问题吗?

4

1 回答 1

1

利用

reqObj.UsePassive = false;

于 2012-05-10T09:28:56.577 回答