![]() |
Download a File using WebClient class
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, |
| All times are GMT. The time now is 03:56 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.