我使用WebClient从服务器下载文件,但是下载的文件不一样(文件大小错误):
这是一个截图(下载的文件在右边):

下面是我的代码:
public void StartDownload(string fileToDownloadLink, string PathToSaveFile) ///////// Try check file type..
{
try
{
using (webClient = new WebClient())
{
//webClient.Encoding = Encoding.UTF8;
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(Client_DownloadFileCompleted);
webClient.DownloadFileAsync(new Uri(fileToDownloadLink), PathToSaveFile);
}
}
catch (WebException e)
{
MessageBox.Show(fileToDownloadLink);
MessageBox.Show(e.ToString());
Worker.CancelAsync();
Application.Exit();
}
}怎么了?
发布于 2018-03-02 21:17:46
我可能知道为什么会发生这种事了..服务器仅支持ASCII码上传到服务器后查看文件大小:enter image description here
我强制编码,它起作用了:)现在文件是一样的:)
https://stackoverflow.com/questions/49060690
复制相似问题