Click here to Skip to main content
15,921,622 members
Please Sign up or sign in to vote.
4.67/5 (2 votes)
See more:
Hello everyone

i am using the following code to fetch image through WebClient

WebClient wc = new WebClient();
           byte[] bytes = wc.DownloadData("");
           MemoryStream ms = new MemoryStream(bytes);
           var image = System.Drawing.Image.FromStream(ms);

that is working fine but i want to save the WebClient downloaded file into to my project folder. how to achieve this.


User image.Save(filePath)?

For your project you mean application folder or your developer project?

Application folder:

your developer project you'll have to put in config file or otherwise save it in some application settings.
Share this answer
WebClient wc = new WebClient();
byte[] bytes = wc.DownloadData("");
System.IO.File.WriteAllBytes("your_path+your_filename+fileextention", bytes);
Share this answer
@p@richit 18-Sep-14 6:29am    
thanks for reply @raju . if my filepath is also a url ("") then it will worked or not ?
raju melveetilpurayil 18-Sep-14 6:36am    
If the location is not local, then you want to upload file
@p@richit 18-Sep-14 6:37am    
have u any idea about that , how to upload it ?
raju melveetilpurayil 18-Sep-14 7:03am    
you can check this for a sample..

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