473,320 Members | 2,122 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,320 software developers and data experts.

Save image from a webpage????

Hi guys,

Anyone knows about how to save a picture from a html page to the hard disk
either in C# or VB.NET? What I have done so far is the following and it
doesn't work. I got an empty image created on the HDD.

_webRequest =
CType(Net.WebRequest.Create("http://wdz.whereis.com.au/gns?user=demo&pass=de
mo&geolang=en&function=map&mode=server_1.2&wgs84x1 y1=-37.82013035956316|144.
98320052639244&radius=800&width=400&height=400&for mat=gif&nourl=1),
Net.HttpWebRequest)

_webResponse = CType(_webRequest.GetResponse(), Net.HttpWebResponse)
_stream = _webResponse.GetResponseStream

Dim inBuf(100000) As Byte
Dim bytesToRead As Integer = CInt(inBuf.Length)
Dim bytesRead As Integer = 0

While bytesToRead > 0
Dim n As Integer = _stream.Read(inBuf, bytesRead, bytesToRead)
If n = 0 Then
Exit While
End If
bytesRead += n
bytesToRead -= n
End While

If Not IO.Directory.Exists(Me.GiveFilePath) = True Then
IO.Directory.CreateDirectory(Me.GiveFilePath)
End If

_fileStream = New IO.FileStream(Me.GiveFilePath & "\map.gif",
IO.FileMode.OpenOrCreate, IO.FileAccess.Write)
_fileStream.Write(inBuf, 0, bytesRead)

_webResponse.Close()
_fileStream.Close()
Thanks

Laszlo
Jul 21 '05 #1
1 4423
Hi,

Probably you need to pass some cookies along with the request?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Laszlo Csabi" <lc****@fantasydesign.net> wrote in message
news:ev**************@tk2msftngp13.phx.gbl...
Hi guys,

Anyone knows about how to save a picture from a html page to the hard disk
either in C# or VB.NET? What I have done so far is the following and it
doesn't work. I got an empty image created on the HDD.

_webRequest =
CType(Net.WebRequest.Create("http://wdz.whereis.com.au/gns?user=demo&pass=de mo&geolang=en&function=map&mode=server_1.2&wgs84x1 y1=-37.82013035956316|144. 98320052639244&radius=800&width=400&height=400&for mat=gif&nourl=1),
Net.HttpWebRequest)

_webResponse = CType(_webRequest.GetResponse(), Net.HttpWebResponse) _stream = _webResponse.GetResponseStream

Dim inBuf(100000) As Byte
Dim bytesToRead As Integer = CInt(inBuf.Length)
Dim bytesRead As Integer = 0

While bytesToRead > 0
Dim n As Integer = _stream.Read(inBuf, bytesRead, bytesToRead)
If n = 0 Then
Exit While
End If
bytesRead += n
bytesToRead -= n
End While

If Not IO.Directory.Exists(Me.GiveFilePath) = True Then
IO.Directory.CreateDirectory(Me.GiveFilePath)
End If

_fileStream = New IO.FileStream(Me.GiveFilePath & "\map.gif",
IO.FileMode.OpenOrCreate, IO.FileAccess.Write)
_fileStream.Write(inBuf, 0, bytesRead)

_webResponse.Close()
_fileStream.Close()
Thanks

Laszlo


Jul 21 '05 #2

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

Similar topics

2
by: Dave Bootsma | last post by:
Is it possible to programatically save a certain image from a certain web page? I want to automatically get a specific graphic from a specific web page programatically so I can automate the...
0
by: prakash | last post by:
Dear Friends I am new guy to Visual C++.NET I've program to save website as a image vc++.net . It have a function "SaveSnapshot" to save the webpage as an image On that function ifor saving...
2
by: programmer2004 | last post by:
Hi I have used WebBrowser control and i want to save the entire webpage including pictures etc. i have called ExecWB method of WebBrowser control with OLECMDEXECOPT_DONTPROMPTUSER flag, but it...
1
by: Laszlo Csabi | last post by:
Hi guys, Anyone knows about how to save a picture from a html page to the hard disk either in C# or VB.NET? What I have done so far is the following and it doesn't work. I got an empty image...
15
by: dgk | last post by:
I'm trying to save the image of a webbrowser control. Not a particular image being shown on the page, but rather the visible display of the webbrowser. Using VS2005 I figured that maybe...
5
by: Jeff | last post by:
Hey asp.net 2.0 I have a webpage which generate thumbnail images. In another webpage I want to display these images... I tryed using this solution: <img ID="photo"...
1
by: | last post by:
I've built an application that scrapes JPG images of webpages and PDF instances of those webpages automatically from an RSS feed. References to the scraped resources are persisted to our database....
1
by: chandan | last post by:
Hi, I am in search of a control that can save image form my webpage. On that web page I am using my own context menu and I disabled the default context menu of IE. Now I want the same...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.