【发布时间】:2012-06-04 08:28:18
【问题描述】:
我正在使用 WebClient 对象上的 UploadFile 方法上传文件。上传文件后,我希望得到确认,根据 MSDN(以及 stackoverflow 上的此处:Should I check the response of WebClient.UploadFile to know if the upload was successful?),我应该能够读取返回的字节数组,但它始终为空。
我做错了什么吗?
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
或者不返回异常就一直成功?
【问题讨论】: