c# - 使用 WebClient.UploadFile 时无响应

标签 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

或者不返回异常就一定成功吗?

最佳答案

对自己的回答:我无法理解它,所以我改用 edt ftp (http://www.enterprisedt.com/)。

关于c# - 使用 WebClient.UploadFile 时无响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10810606/

相关文章:

c# - DateTime AddMonths 正在乘以

shell - 如何从SVN导出文件到远程FTP服务器

python - 使用 Python ftplib 限制 FTP 下载

vb.net - 使用 WebClient 处理 VB.NET SSIS 脚本中的异常(FTP 下载)

c# - 等待多个异步 POST 请求

c# - 使用 C# 检查 Linux 服务器中的文件是否已通过 .Net Core 更新

c# - 循环遍历标志枚举,同时忽略组合类型

java - 在 Java (Apache Net Commons) 中下载整个 FTP 目录

c# - WebClient 请求返回空字符串

c# - 如何从数据库 SQL 添加组合框值