使用WebClient.UploadFile时无响应

时间:2012-05-30 05:47:25

标签: c# ftp webclient

我正在使用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

如果它没有返回异常,它总是成功吗?

1 个答案:

答案 0 :(得分:0)

回答自己:我无法理解,所以我转而使用edt ftp(http://www.enterprisedt.com/)。