473,378 Members | 1,360 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,378 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 4425
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: 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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.