我剛剛編寫了一個簡單的FTP控制檯應用程序,將本地服務器上的文件上傳到遠程FTP站點。在實際傳輸文件之前,似乎一切正常。出於某種原因,而不是將文件上載到指定的FTP站點,它將整個文件本地存儲在Debug文件夾中,沒有文件類型,並且命名爲與FTP站點的IP相同。我在想這與Visual Studio的調試有關。有人可以給我一些指導嗎?C#FTP應用程序上傳到本地目錄
這裏是我用來嘗試上傳到FTP站點的字符串數組中的每個文件的代碼。
private static void Upload(string ftpServer, string userName, string password, string filename)
{
using (var client = new WebClient())
{
client.Credentials = new NetworkCredential(userName, password);
client.UploadFile(ftpServer, "STOR", filename);
}
}
是什麼'ftpServer'和'filename'的價值? – Yahia
他們在上面的方法傳遞時,FTP是通過IP在一個字符串 「靜態類全局 { 公共靜態字符串GetIPAddress { {返回‘206.xxx.xxx.xxx’; } } }' – John