gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 16:30:50 27 4
gpt4 key购买 nike

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com