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.WebRe quest.Create("h ttp://wdz.whereis.com .au/gns?user=demo&p ass=de
mo&geolang=en&f unction=map&mod e=server_1.2&wg s84x1y1=-37.820130359563 16|144.
98320052639244& radius=800&widt h=400&height=40 0&format=gif&no url=1),
Net.HttpWebRequ est)
_webResponse = CType(_webReque st.GetResponse( ), Net.HttpWebResp onse)
_stream = _webResponse.Ge tResponseStream
Dim inBuf(100000) As Byte
Dim bytesToRead As Integer = CInt(inBuf.Leng th)
Dim bytesRead As Integer = 0
While bytesToRead > 0
Dim n As Integer = _stream.Read(in Buf, bytesRead, bytesToRead)
If n = 0 Then
Exit While
End If
bytesRead += n
bytesToRead -= n
End While
If Not IO.Directory.Ex ists(Me.GiveFil ePath) = True Then
IO.Directory.Cr eateDirectory(M e.GiveFilePath)
End If
_fileStream = New IO.FileStream(M e.GiveFilePath & "\map.gif",
IO.FileMode.Ope nOrCreate, IO.FileAccess.W rite)
_fileStream.Wri te(inBuf, 0, bytesRead)
_webResponse.Cl ose()
_fileStream.Clo se()
Thanks
Laszlo
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.WebRe quest.Create("h ttp://wdz.whereis.com .au/gns?user=demo&p ass=de
mo&geolang=en&f unction=map&mod e=server_1.2&wg s84x1y1=-37.820130359563 16|144.
98320052639244& radius=800&widt h=400&height=40 0&format=gif&no url=1),
Net.HttpWebRequ est)
_webResponse = CType(_webReque st.GetResponse( ), Net.HttpWebResp onse)
_stream = _webResponse.Ge tResponseStream
Dim inBuf(100000) As Byte
Dim bytesToRead As Integer = CInt(inBuf.Leng th)
Dim bytesRead As Integer = 0
While bytesToRead > 0
Dim n As Integer = _stream.Read(in Buf, bytesRead, bytesToRead)
If n = 0 Then
Exit While
End If
bytesRead += n
bytesToRead -= n
End While
If Not IO.Directory.Ex ists(Me.GiveFil ePath) = True Then
IO.Directory.Cr eateDirectory(M e.GiveFilePath)
End If
_fileStream = New IO.FileStream(M e.GiveFilePath & "\map.gif",
IO.FileMode.Ope nOrCreate, IO.FileAccess.W rite)
_fileStream.Wri te(inBuf, 0, bytesRead)
_webResponse.Cl ose()
_fileStream.Clo se()
Thanks
Laszlo
Comment