Download File Using C#
-
Upload
shopnopathik-aion -
Category
Documents
-
view
17 -
download
0
description
Transcript of Download File Using C#
-
Searchforarticles,questions,tipsquick answers discussions community helparticles
Articles Web Development ASP.NET Howto
Rate:tejasbhalani, 30 May 2012 CPOL 169.7K 13
Download File Using C#
Download file using C#.
IntroductionThis article describes code to download a file using C#...
BackgroundWhile browsing forums today I came across a question which asked for a solution to download a file from a web server programmatically. The solution is very simple andbelow is the code which achieves the goal. Here I am downloading a file asynchronously on Button Click.
Using the codeHide Copy Code
4.53 15 votes
10,500,000 members 70,406 online 211 Sign out jokercracker
-
privatevoidbuttonDownloadFile_Click(objectsender,EventArgse){stringurl=@"http://www.thereforesystems.com/wpcontent/uploads/2008/08/image35.png";//CreateaninstanceofWebClientWebClientclient=newWebClient();//HookupDownloadFileCompletedEventclient.DownloadFileCompleted+=newAsyncCompletedEventHandler(client_DownloadFileCompleted);
//Startthedownloadandcopythefiletoc:\tempclient.DownloadFileAsync(newUri(url),@"c:\temp\image35.png");}
voidclient_DownloadFileCompleted(objectsender,AsyncCompletedEventArgse){MessageBox.Show("Filedownloaded");}
You can also download the file synchronously using WebClient.DownloadFile() method.
LicenseThis article, along with any associated source code and files, is licensed under The Code Project Open LicenseCPOL
Share
About the Author
You may also be interested in...
EMAIL TWITTER
-
Add a Comment or Question Search Comments Go
File Download in ASP.NET and Tracking theStatus of Success/Failure of Download
I Cant Believe Its Not Multisite!
Resume Support for File Downloads Red Hat JBoss BPM Suite 6 compared to Appian7 BPM Suite
File List Downloader Red Hat JBoss BPM Suite 6 Compared toPegasystems Pega 7 BPM
Comments and Discussions
Profile popupsSpacing Relaxed Layout Normal Per page 25 Update
First Prev Next
MohamedImtiyaz.net 10Feb15 19:25
jayprakashjaysun 2Dec14 17:17
Member 10795245 29Sep14 18:54
aman bhardwaj 10Sep14 13:51
Chan Nyein 13Apr14 8:54
Download files from HTTPS
Download file from secure folder
My vote of 1
regarding youtube
My vote of 5
-
Permalink | Advertise | Privacy | Terms of Use | Mobile Web01 | 2.8.1509020.2 | Last Updated 30 May 2012 Select Language
Article Copyright 2012 by tejasbhalaniEverything else Copyright CodeProject, 19992015
Layout: fixed |fluid
Siva Hyderabad 28Feb14 10:17
Rahim Lotfi 20Feb14 2:14
mehrarohit 13Feb14 10:20
ali yeganeh 1Nov12 1:51
Member 9319962 5Feb13 22:44
kishore doni 28Aug12 16:57
Last Visit: 20Sep15 13:38 Last Update: 23Sep15 20:38 Refresh 1
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
Like it
hello
Download multiple files to a folder from a url
My vote of 4
Re: My vote of 4
My vote of 4