1
我使用WebClient對象上的UploadFile方法上傳文件。當文件上傳時,我想要得到一個確認,並根據MSDN(也在這裏的計算器:Should I check the response of WebClient.UploadFile to know if the upload was successful?)我應該能夠讀取返回的字節數組,但始終是空的。使用WebClient.UploadFile時無響應
我做錯了什麼嗎?
WebClient FtpClient = new WebClient();
FtpClient.Credentials = new NetworkCredential("test", "test");
byte[] responseArray = FtpClient.UploadFile("ftp://localhost/Sample.rpt", @"C:\Test\Sample.rpt");
string s = System.Text.Encoding.ASCII.GetString(responseArray);
Console.WriteLine(s); //Empty string
或者它總是成功,如果它不返回異常?