Serv-U FTP Server在重命名文件时关闭会话

时间:2016-02-10 18:02:41

标签: c# ftp

我尝试使用以下C#代码在我们的FTP服务器上移动文件:

try  {
  FtpWebRequest request = WebRequest.Create(sourcefile) as FtpWebRequest;
  request.Credentials = new NetworkCredential(user, pw);
  request.UseBinary = true;
  request.Method = WebRequestMethods.Ftp.Rename;
  request.RenameTo = "/OtherFolder/newFileName";
  request.GetResponse();
}
catch (WebException e) {
  log.writeError("Error while moving " + file + " on " + downloadServer + " !");
  log.writeError(((FtpWebResponse)e.Response).StatusDescription);
  log.writeError(e.Message);
}

这曾经工作得非常好,如果我在本地机器上运行它仍然可以正常工作,但如果我在服务器上运行它,文件就不会被移动。

Serv-U日志显示(我添加了德语行的英文翻译):

[02] Wed 10Feb16 18:33:30 - (023490) Verbunden zu (connected to) xxx.xxx.61.245 (lokale Adresse (local address) xxx.xxx.63.243, Anschluss 21)
[21] Wed 10Feb16 18:33:30 - (023490) 220 Serv-U FTP Server v12.1 ready...
[20] Wed 10Feb16 18:33:30 - (023490) USER ABC
[21] Wed 10Feb16 18:33:30 - (023490) 331 User name okay, need password.
[20] Wed 10Feb16 18:33:30 - (023490) PASS **********
[02] Wed 10Feb16 18:33:30 - (023490) Benutzer "ABC" angemeldet (User "ABC" connected)
[21] Wed 10Feb16 18:33:30 - (023490) 230 User logged in, proceed.
[20] Wed 10Feb16 18:33:30 - (023490) OPTS utf8 on
[21] Wed 10Feb16 18:33:30 - (023490) 200 OPTS UTF8 is set to ON.
[20] Wed 10Feb16 18:33:30 - (023490) PWD
[21] Wed 10Feb16 18:33:30 - (023490) 257 "/C:/FTP/xxx" is current directory.
[20] Wed 10Feb16 18:33:30 - (023490) CWD /C:/FTP/xxx/xxx/xxx/xxx/
[21] Wed 10Feb16 18:33:30 - (023490) 250 Directory changed to /C:/FTP/xxx/xxx/xxx/xxx
[20] Wed 10Feb16 18:33:30 - (023490) RNFR Filename.zip
[21] Wed 10Feb16 18:33:30 - (023490) 350 File or directory exists, ready for destination name.
[02] Wed 10Feb16 18:33:30 - (023490) Sitzung geschlossen (Session closed)
[02] Wed 10Feb16 18:33:30 - (023490) Benutzer "ABC" abgemeldet (User ABC disconnected)

简而言之:当服务器等待“RNTO”时会话关闭。有没有理由说我的代码会导致会话关闭?为什么在我的机器上执行但在服务器上执行却没有问题? 从同一台服务器下载和上传也可以正常工作。

Serv-U的“文档”实际上没有用处: Link

编辑:我添加了我的Catch块。

StatusDescription是“350文件或目录存在,准备好目的地名称。”

e.Message是“Die zugrunde liegende Verbindung wurde geschlossen:Unbekannter Fehler beim Empfangen ..”(基础连接已关闭:接收时发生意外错误) Microsoft指向错误的链接:https://support.microsoft.com/en-us/kb/826210

文件不是很大,下载/上传工作正常......

0 个答案:

没有答案