我试图将文件上传到FileZilla FTP服务器。我已经在我的电脑中安装了服务器,并且正在使用简单的C#脚本来上传文件。当我从同一台机器运行脚本时,它可以正常工作。当我试图从相同或不同的局域网从另一台计算机上运行脚本我这有问题:当使用WebClient.UploadFileAsync时,某些机器上的文件未上传到FTP服务器
(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")
。
也许分享您的上传功能的一些C#代码? – rinukkusu
检查我更新的问题。 –
什么是错误信息? –