473,782 Members | 2,699 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting image from wewbsite

Does anybody know how you can extract an image fron a webpage loaded into a
webbrowser control and either save it to file OR save it in a database?

Cheers,
Johnny J.
Nov 16 '07 #1
10 1865


"Johnny Jörgensen" <jo**@altcom.se wrote in message
news:Ot******** ******@TK2MSFTN GP02.phx.gbl...
Does anybody know how you can extract an image fron a webpage loaded into
a webbrowser control and either save it to file OR save it in a database?

Cheers,
Johnny J.
You need to read in the image as if you were reading in a webpage....firs t,
open the web page and parse the path to the image...then, you can use the
following code to get the byte-array of the image and store to a file or
data column in a database.

// BEGIN C#

string url =
@"http://www.co.merced.c a.us/CountyWeb/images/GeneralActive.g if";
HttpWebRequest request =
(HttpWebRequest ) WebRequest.Crea te(url);
HttpWebResponse response =
(HttpWebRespons e) request.GetResp onse();

byte[] bytes;
using (Stream stream = response.GetRes ponseStream()) {
bytes = new byte[response.Conten tLength];
stream.Read(byt es, 0, bytes.Length);
}

// Now we have a byte array to do as we wish, saving to a file
now.
FileStream fs = File.Create(@"C :\GeneralActive .gif");
fs.Write(bytes, 0, bytes.Length);
fs.Close();

// OR write to a database.
// To do this, create an IMAGE (SQL Server) column and just copy
// the byte array into the field for a DataRow. An Image column
// maps to a byte-array in a DataColumn in a DataRow.

// END C#

There may be an easier or better way in a more recent version of the .Net
Framework though... :)
HTH,
Mythran

Nov 16 '07 #2
Johny,

As soon as you know its url location you can download it using

DownloadFile
http://msdn2.microsoft.com/en-us/lib...le(VS.71).aspx

To get that in a webbrowser you mostly needs a lot of mshtml

http://support.microsoft.com/kb/311284

Cor

Nov 16 '07 #3
"Johnny Jörgensen" <jo**@altcom.se schrieb:
Does anybody know how you can extract an image fron a webpage loaded into
a webbrowser control and either save it to file OR save it in a database?
'My.Computer.Ne twork.DownloadF ile'
'System.Net.Web Client.Download File'

You can store the binary data in the database as a BLOB.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 16 '07 #4
Thanks for the suggestions all of you.

Howevet, having had time to think about it, it seems like I'm missing
something here.

You see, as I wrote, I already have a webpage loaded in a webbrowser
containing the image I want to save to a database field.

So there should be no reason for downloading it AGAIN (using extra time to
do that). There MUST be a way to "pluck out" the image from the webbrowser
control in a form that's database saveable.

Cheers,
Johnny J.

"Johnny Jörgensen" <jo**@altcom.se skrev i meddelandet
news:Ot******** ******@TK2MSFTN GP02.phx.gbl...
Does anybody know how you can extract an image fron a webpage loaded into
a webbrowser control and either save it to file OR save it in a database?

Cheers,
Johnny J.

Nov 16 '07 #5
Johnny,

The following will help you do what you want:

http://msdn2.microsoft.com/en-us/lib...3052001_topic2

Be aware, however, that because of security issues, the UI to indicate
where to save the image must be presented, there is no way around it.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Johnny Jörgensen" <jo**@altcom.se wrote in message
news:Od******** *****@TK2MSFTNG P03.phx.gbl...
Thanks for the suggestions all of you.

Howevet, having had time to think about it, it seems like I'm missing
something here.

You see, as I wrote, I already have a webpage loaded in a webbrowser
containing the image I want to save to a database field.

So there should be no reason for downloading it AGAIN (using extra time to
do that). There MUST be a way to "pluck out" the image from the webbrowser
control in a form that's database saveable.

Cheers,
Johnny J.

"Johnny Jörgensen" <jo**@altcom.se skrev i meddelandet
news:Ot******** ******@TK2MSFTN GP02.phx.gbl...
>Does anybody know how you can extract an image fron a webpage loaded into
a webbrowser control and either save it to file OR save it in a database?

Cheers,
Johnny J.

Nov 17 '07 #6
Johnny,

There is no image loaded in your webbrowser, a webbrowser is just using the
IE part of the OS. In the pages there is an image tag to the url about we
all are talking about in a way. That URL you can find using MSHTML (Which is
nothing more then the representation of the DHTML object model often called
***the*** DOM).

Cor

Nov 17 '07 #7

"Joey Joe Joe" <no@nothing.com schreef in bericht
news:%2******** *******@TK2MSFT NGP03.phx.gbl.. .
That's exactly where they are. They're in your Temporary Internet Files
folder.
Which you could find in W98 and IE4 direct in the C drive folder, however a
little bit changed.

In XP it has all kind of GUID like other names, in Vista I don't even see it
even anymore.

Beside that are images mostly very short in cache because that they have
mostly a retention time of 0.

Cor

Nov 18 '07 #8
That's because the folder is hidden, but it's still there. In Vista (unless
you move it):

C:\Users\.....\ AppData\Local\M icrosoft\Window s\Temporary Internet Files

"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:A7******** *************** ***********@mic rosoft.com...
>
"Joey Joe Joe" <no@nothing.com schreef in bericht
news:%2******** *******@TK2MSFT NGP03.phx.gbl.. .
>That's exactly where they are. They're in your Temporary Internet Files
folder.
Which you could find in W98 and IE4 direct in the C drive folder, however
a little bit changed.

In XP it has all kind of GUID like other names, in Vista I don't even see
it even anymore.

Beside that are images mostly very short in cache because that they have
mostly a retention time of 0.

Cor
Nov 18 '07 #9

"Joey Joe Joe" <no@nothing.com wrote in message
news:um******** ******@TK2MSFTN GP02.phx.gbl...
That's because the folder is hidden, but it's still there. In Vista
(unless you move it):

C:\Users\.....\ AppData\Local\M icrosoft\Window s\Temporary Internet Files

"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:A7******** *************** ***********@mic rosoft.com...
>>
"Joey Joe Joe" <no@nothing.com schreef in bericht
news:%2******* ********@TK2MSF TNGP03.phx.gbl. ..
>>That's exactly where they are. They're in your Temporary Internet Files
folder.
Which you could find in W98 and IE4 direct in the C drive folder, however
a little bit changed.

In XP it has all kind of GUID like other names, in Vista I don't even see
it even anymore.

Beside that are images mostly very short in cache because that they have
mostly a retention time of 0.

Cor
Simplest way to find the temp files in Vista is to use Tools/Internet
Options/General Tab.

Click on Settings then View Files

LS

Nov 18 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4234
by: karimL | last post by:
Hi, how can I retrieve the height and width of a System.Web.UI.WebControls.Image after populating it's ImageUrl property. It's seems not to be filled ? Does someone have a solution ? Thanks Karim
11
2024
by: KarimL | last post by:
Thanks for your advices... but i need to get the Image height because i dynamically resize the height of my webcontrol based on the image height. More i just have the url (relative parth) to the the image but in design time mode all variables concerning Server or Context ar not set ! ...so I can't use MapPath function to obtain the physical parth of the picture ... So my second question is how to retrieve the physical root path of the...
3
3090
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are displayed. Can anybody know this issue and help me to resolve this. In past i received the response saying that i should download the image first and then parse the actual response and modify the src attribute of the
5
1353
by: Aryan | last post by:
Hi All, I am creating an image(.gif) file on server Using ASP and ShotGraph Third Party Tool, now with the help of this .gif image I am creating another Thumbnail image in ASP.NET. Now this newly created Thumbnail is been shown in ASP.NET page in IFrame, I have delete Button in my ASP.NET page, Now on Click of this Delete Button i want to delete both the images. But I am not able to delete that .gif file which is been created by ASP page...
2
1662
by: soma.gunasekaran | last post by:
Hi All , I've stored the Image file..... But i want to retriving the Image files from MSACCSS 2003 (JPEG,bmp,Gif and etc....) So Pls help me........ help me............... Thanking you, Somasundaram G
3
22533
by: Andrzej | last post by:
I have a picturebox on my C# .NET form. The picturebox size mode is set to zoom. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and display (in the status bar) the image coordinates of the mouse location. However, if I use the picturebox's MouseMove event, I am getting the coordinates of the mouse over the PICTUREBOX, not the actual image underneath that (which is zoomed). i.e....
5
2474
by: Emmi | last post by:
Hi there, just starting in PHP and found some code that would switch out pages depending on link clicked. It worked great loading different pages. Then I thought I would try the same code by calling an image instead of a page. When I use the following code, what happens is the rest of the page loads fine, but instead of getting an image I'm getting junk on the screen. Could anyone tell me what I'm doing wrong? Here is my script: <?php ...
10
1200
by: Johnny Jörgensen | last post by:
Does anybody know how you can extract an image fron a webpage loaded into a webbrowser control and either save it to file OR save it in a database? Cheers, Johnny J.
2
2054
by: hgarg | last post by:
The onpaint() is getting called before calculating the required parameters by listBox1_SelectedIndexChanged function. I tried calling it at the end of this function. But of no use. Due to this issue only half of the diagram is getting painted,some lines are missing in the diagram. private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e) { string str=listBox1.SelectedItem.ToString(); string str1=null;...
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10308
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10076
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7486
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6729
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5375
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4040
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.