Download a file using WebClient class

Discussion in 'ASP .Net Web Controls' started by sweety, Jul 31, 2007.

  1. sweety

    sweety Guest

    Hi,
    I'll download some file from our client site which is accessed after
    logging in through some credentials. There I have the option to download a
    file. I'll set it to download, and the download is started message apprears
    on the page.
    After a while I get an email saying that down load is complete. Then I'll go
    back to the same page where I initiated download, I'll have an option to view
    downloaded file.
    I'll view the file and save the file on to my disk. This is the process I'm
    following for a long time. In order to automate the download process I
    researched some articles and have developed an asp.net web application using
    WebClient.
    I'm not sure why it is not working. When I run the application, it should
    initiate the download process. But its not doing it.
    Am I missing anything here?
    This is the code I've written in the application.
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Net;
    using System.IO;

    namespace FileDownload1
    {
    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    WebClient Client = new WebClient();

    NetworkCredential credential =
    new NetworkCredential("userid", "pwd", "domain name");
    Client.Credentials = credential;

    Client.DownloadFile("Url", "C:\file1.xslx");


    }
    }
    }

    I'm struggling with this problem for a number of days, please any body help
    me.
    Thanks,
     
    sweety, Jul 31, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Grant Harmeyer

    WebClient Class / Upload File / IIS 405 Error

    Grant Harmeyer, Sep 7, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    4,537
    Sayed Hashimi
    Sep 8, 2004
  2. Web learner
    Replies:
    0
    Views:
    751
    Web learner
    Apr 18, 2006
  3. natzol
    Replies:
    0
    Views:
    493
    natzol
    Dec 1, 2006
  4. =?Utf-8?B?c3dlZXR5?=

    Download a File using WebClient class

    =?Utf-8?B?c3dlZXR5?=, Jul 31, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    496
    =?Utf-8?B?c3dlZXR5?=
    Jul 31, 2007
  5. Vasko Peter
    Replies:
    0
    Views:
    137
    Vasko Peter
    Aug 13, 2004
Loading...

Share This Page