Click here to Skip to main content
16,015,393 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My Code:
FileInfo fileinfo = new FileInfo(@"\\10.16.20.70\website.com\wwwroot\im_online.png");

           Response.Clear();
           Response.ClearHeaders();
           Response.ClearContent();
           Response.AppendHeader("Content-Disposition", "attachment; filename =im_online.png ");
           Response.AppendHeader("Content-Length", fileinfo.Length.ToString());
           Response.ContentType = "application/download";
           Response.WriteFile(fileinfo.FullName);
           Response.Flush();
           Response.Close();
           Response.End();


Error:
Logon failure: unknown user name or bad password.

How to set username and password for my remote server to download the file in it?.
Posted

Use the WebClient.DownloadFile[^] method.

Quote:
The DownloadFile method downloads to a local file data from the URI specified by in the address parameter. This method blocks while downloading the resource. To download a resource and continue executing while waiting for the server's response, use one of the DownloadFileAsync methods.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900