我正在做将文件从一台服务器上传到另一台服务器的代码,以下是我的代码:
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进入被动模式()
你能告诉我这有什么问题吗?