使用WebClient.UploadFileAsync时,某些计算机上的文件未上载到FTP服务器

时间:2015-11-23 10:41:03

标签: c# ftp webclient filezilla

我正在尝试将文件上传到FileZilla FTP服务器。我在我的电脑上设置了服务器,我使用一个简单的C#脚本来上传文件。当我从同一台机器运行脚本时,它可以正常工作。当我尝试从相同或不同的局域网中的另一台计算机运行脚本时,我遇到了以下问题:

 (not logged in) (ClientIP)> USER userID
 (not logged in) (ClientIP)> 331 Password required for userID
 (not logged in) (ClientIP)> PASS ***************
  userID (ClientIP)> 230 Logged on
  userID (ClientIP)> OPTS utf8 on
  userID (ClientIP)> 202 UTF8 mode is always enabled. No need to send this command.
  userID (ClientIP)> PWD
  userID (ClientIP)> 257 "/" is current directory.
  userID (ClientIP)> TYPE I
  userID (ClientIP)> 200 Type set to I
  userID (ClientIP)> PASV
  userID (ClientIP)> 227 Entering Passive Mode (ClientIP)

这会引起什么问题?我从自己的电脑收到的消息如下:

(not logged in) (pcIP)> USER userID
(not logged in) (pcIP)> 331 Password required for userID
(not logged in) (pcIP)> PASS ***************
userID (pcIP)> 230 Logged on
userID (pcIP)> OPTS utf8 on
userID (pcIP)> 202 UTF8 mode is always enabled. No need to send this command.
userID (pcIP)> PWD
userID (pcIP)> 257 "/" is current directory.
userID (pcIP)> TYPE I
userID (pcIP)> 200 Type set to I
userID (pcIP)> PASV
userID (pcIP)> 227 Entering Passive Mode ((pcIP))
userID (pcIP)> STOR myTempDoc.pdf
userID (pcIP)> 150 Opening data channel for file upload to server of "/myTempDoc.pdf"
userID (pcIP)> 226 Successfully transferred "/myTempDoc.pdf"

唯一的区别是在第一种情况下我无法上传所需的文件。这有什么区别?

uploadX(string path)
{
    string host = "ftp://ip:port/";
    string user = "userID";
    string pass = "password";
    WebClient Xclient = new System.Net.WebClient();
    Uri uri = new Uri(host + new FileInfo(path).Name);
    Xclient.Credentials = new System.Net.NetworkCredential(user, pass);
    Xclient.UploadFileAsync(uri, "STOR", path);
}

在我的主要功能中,我致电uploadX("docName")

0 个答案:

没有答案