Unauthorized exception when trying to download a file

N

news.microsoft.com

Hi All,

I am trying to download a file from a C# Windows Application (Ex: from
http://localhost/fileName" to "C:\fileName1") using the below code

WebClient myWebClient = new WebClient();

myWebClient.DownloadFile("http://localhost/UploadFiles/File.xml","sample.xml
");



But I am getting the following Exception: "System.Net.WebException: The
remote server returned an error: (401) Unauthorized"

Anyone have idea why I get this error.



Thanks in Advance

Pradeep
 
H

Herfried K. Wagner [MVP]

* "news.microsoft.com said:
I am trying to download a file from a C# Windows Application (Ex: from
http://localhost/fileName" to "C:\fileName1") using the below code

WebClient myWebClient = new WebClient();

myWebClient.DownloadFile("http://localhost/UploadFiles/File.xml","sample.xml
");

But I am getting the following Exception: "System.Net.WebException: The
remote server returned an error: (401) Unauthorized"

<http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html>
-> "10.4.2 401 Unauthorized"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top