How do i download a file that requires password

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gary2008
    New Member
    • Dec 2008
    • 1

    #1

    How do i download a file that requires password

    Greeting all,

    I was trying to use C# to download a file that needs log-in:

    string strDownloadURL = "http://www.cchere.com/list.rdl";
    WebClient Client = new WebClient();
    Client.Download File(strDownloa dURL, "c:\\s.rdlc ");

    However the code returns "Authorizat ion Failure" error, because that URL requires login.

    I DO have the username and password that will allow me to download the file from web browser. How can i do this from C# code?

    Thanks a lot!

    Gary
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    You will need to send the authenticate header with your request.
    Check the http documentation for how to create it, or, I *THINK* the HttpWebRequest class has a way to add the credentials.

    Comment

    Working...