473,426 Members | 2,207 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,426 software developers and data experts.

Web Browser - Saving Images

I trying to write a program that will go to a website and get all the images and then save then on to a local drive.

I am using a mshtml.HTMLImg variable and then directcasting the web page to mshtml document, and then retriving all images. I am able to retrieve all the names of the images. How do I store these images on to the local drive? Any help is appreciated.

Thanks.
Mar 27 '08 #1
2 1271
balabaster
797 Expert 512MB
This demonstrates the concept of saving a file from a remote server to the local disk:
Expand|Select|Wrap|Line Numbers
  1. using System.Net;
  2. using System.IO;
  3.  
  4. static public void DownloadImage(string url, string outputFile)
  5. {
  6.     byte[] byteBuffer;
  7.     HttpWebRequest Req = (HttpWebRequest)WebRequest.Create(url);
  8.     WebResponse Rsp = Req.GetResponse();
  9.     Stream oStrm = Rsp.GetResponseStream();
  10.     using (BinaryReader oBR = new BinaryReader(oStrm))
  11.     {
  12.         byteBuffer = oBR.ReadBytes(500000);
  13.         oBR.Close();
  14.     }
  15.     Rsp.Close();
  16.     File.WriteAllBytes(outputFile, url);
  17. }
Just dump it into your code and call it by DownloadImage(RemoteFile, LocalFile);
Mar 27 '08 #2
Cool. This works. Thanks
Mar 28 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Nathan Sokalski | last post by:
I am using ASP.NET, VB.NET, and GDI+ to dynamically create images for webpages. When I right-click on the dynamically created image to try to save it to my hard drive, which I send as...
3
by: Nathan Sokalski | last post by:
I am using ASP.NET, VB.NET, and GDI+ to dynamically create images for webpages. When I right-click on the dynamically created image to try to save it to my hard drive, which I send as...
3
by: Nathan Sokalski | last post by:
I am using ASP.NET, VB.NET, and GDI+ to dynamically create images for webpages. When I right-click on the dynamically created image to try to save it to my hard drive, which I send as...
41
by: Cartoper | last post by:
I hear it is possible to disable the web browsers print function, does anyone know how to do that?
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.