Unauthorized exception when trying to download a file

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
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
 
* "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"
 
Back
Top