我正在使用 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
或者不返回异常就一定成功吗?
最佳答案
对自己的回答:我无法理解它,所以我改用 edt ftp (http://www.enterprisedt.com/)。
关于c# - 使用 WebClient.UploadFile 时无响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10810606/