我試圖將文件上傳到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
檢查我更新的問題。 –
什麼是錯誤信息? –