简体   繁体   English

C#WebClient下载0字节的文件

[英]C# webclient Downloads files with 0 bytes

I tried to download a file from a URL using Webclient, but the downloaded files can't be opened and their size is 0 bytes, 我尝试使用Webclient从URL下载文件,但是无法打开下载的文件,文件大小为0字节,

could you please help me figure out what is the problem 你能帮我找出问题所在吗

below is the code i'm using : 以下是我正在使用的代码:

using (WebClient client = new WebClient())
{
client.DownloadFile("https://anticipa-pre.crm4.dynamics.com/Activities/Attachment/download.aspx?AttachmentType=5&IsNotesTabAttachment=1&AttachmentId=dba4e278-2110-e911-8140-5065f38ada91&CRMWRPCToken=tzNg2xRKEemBV1Bl84vUEa8EEKjO6%2fTiao%2b9Wa9pQd%2f2CmDOgnckhoaIGqzrXSp6&CRMWRPCTokenTimeStamp=636838278955012633", 
                        @"C:\Users\ayousbai\DNIs\dni7.jpg");
}

Use Fiddler, or your browser, to test the download. 使用Fiddler或您的浏览器来测试下载。 Then you might see the error response or login screen. 然后,您可能会看到错误响应或登录屏幕。

In Firefox, I was redirected to: 在Firefox中,我被重定向到:

login.microsoftonline.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM