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

http download

How can I retrieve an image (.jpg) from a web site using http with VB
dotnet?

thanks
Bill

Nov 20 '05 #1
11 1536
Cor
Hi Belgie,

Have a look to webclient.downloadfile

Very simple with that

I hope this helps?

Cor
How can I retrieve an image (.jpg) from a web site using http with VB
dotnet?

Nov 20 '05 #2
"belgie" <be****@hns.com> schrieb
How can I retrieve an image (.jpg) from a web site using http with
VB dotnet?

http://msdn.microsoft.com/library/en...nginternet.asp

sub topics
- requesting data
- Using applicaton protocols -> HTTP
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
* "belgie" <be****@hns.com> scripsit:
How can I retrieve an image (.jpg) from a web site using http with VB
dotnet?


Documentation + sample:

<http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemnetwebclientclassdownloadfiletopic.asp>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Hi,

Dim img As Bitmap

Dim wc As New System.Net.WebClient

img = New
Bitmap(wc.OpenRead("http://images.ibsys.com/orlc/images/weather/auto/doppler_640x480.gif"))

PictureBox1.Image = img

Ken

-----------------------

"belgie" <be****@hns.com> wrote in message
news:eV**************@TK2MSFTNGP09.phx.gbl...
How can I retrieve an image (.jpg) from a web site using http with VB
dotnet?

thanks
Bill

Nov 20 '05 #5
Cor
Hi Ken,

Why would you do that?

Dim img As Bitmap
Dim wc As New System.Net.WebClient
img = New

Bitmap(wc.OpenRead("http://images.ibsys.com/orlc/images/weather/auto/doppler
_640x480.gif"))

You convert the gif while you can do

webclient.downloadfile("http://images.ibsys.com/orlc/images/weather/auto/dop
pler_640x480.gif")

Cor
Nov 20 '05 #6
Hi,

Just showing another way to do it.

Ken
-----------
"Cor" <no*@non.com> wrote in message
news:uR**************@TK2MSFTNGP11.phx.gbl...
Hi Ken,

Why would you do that?

Dim img As Bitmap
Dim wc As New System.Net.WebClient
img = New

Bitmap(wc.OpenRead("http://images.ibsys.com/orlc/images/weather/auto/doppler
_640x480.gif"))

You convert the gif while you can do

webclient.downloadfile("http://images.ibsys.com/orlc/images/weather/auto/dop
pler_640x480.gif")

Cor

Nov 20 '05 #7
Cor
Hi Ken,

Mostly I like that, but for this I think it is not that good.
As far as I know will the gif loose parts of the pixels doing this.
(If I am wrong in the last sentence, it is only what I did read)

:-)

Cor
Nov 20 '05 #8
When I try downloadfile, I always get

"An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: The remote server returned an error: (404) Not
Found."

I used the example from the documentation verbatim. Is this a LAN/firewall
issue possibly? I have tried to download image files which I can see in a
browser.
Function WebClientTest()
Dim remoteUri As String =
"http://www.contoso.com/library/homepage/images/"
Dim fileName As String = "ms-banner.gif"
Dim myStringWebResource As String = Nothing
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
' Concatenate the domain with the Web resource filename. Because
DownloadFile
'requires a fully qualified resource name, concatenate the domain
with the Web resource file name.
myStringWebResource = remoteUri + fileName
Console.WriteLine("Downloading File ""{0}"" from ""{1}"" ......." +
ControlChars.Cr + ControlChars.Cr, fileName, myStringWebResource)
' The DownloadFile() method downloads the Web resource and saves it
into the current file-system folder.
myWebClient.DownloadFile(myStringWebResource, fileName)
Console.WriteLine("Successfully Downloaded file ""{0}"" from
""{1}""", fileName, myStringWebResource)
Console.WriteLine((ControlChars.Cr + "Downloaded file saved in the
following file system folder:" + ControlChars.Cr + ControlChars.Tab +
Application.StartupPath))
End Function
"Cor" <no*@non.com> wrote in message
news:uR**************@TK2MSFTNGP11.phx.gbl...
Hi Ken,

Why would you do that?

Dim img As Bitmap
Dim wc As New System.Net.WebClient
img = New

Bitmap(wc.OpenRead("http://images.ibsys.com/orlc/images/weather/auto/doppler _640x480.gif"))

You convert the gif while you can do

webclient.downloadfile("http://images.ibsys.com/orlc/images/weather/auto/dop pler_640x480.gif")

Cor

Nov 20 '05 #9
Cor
Hi Belgie,

I know minimum two situations that I cannot get all files.
Situation one, the image is on a protected part of the disk (the page
can read them but you not)
Situation two, the image is first streamwritted from a database to a
tempory internet page.

Till now I could not get a method to get them,

To get the first one is very difficult and I think illegal because it is in
my opinion a kind of hacking.

For the second situaton I think that it maybe is possible as you open in the
same time the corresponding webpage, but I never tried.

Cor
Nov 20 '05 #10
This works with no problem in VB6, with a INET control on a form, with the
same URL which doesn't work with the VB dotNet WebClient:

Public Function GetInternetFile(Inet1 As Inet, myURL As String, DestDIR As
String) As Boolean

Dim myData() As Byte
Dim intFree As Integer

If Inet1.StillExecuting = True Then Exit Function
myData() = Inet1.OpenURL(myURL, icByteArray)

intFree = FreeFile

Open DestDIR For Binary Access Write As #intFree
' Open App.Path & "\test.htm" For Binary Access Write As #intFree
Put #intFree, , myData()
Close #intFree
End Function

Thanksfor your help!
Bil
"belgie" <be****@hns.com> wrote in message
news:#h**************@TK2MSFTNGP11.phx.gbl...
When I try downloadfile, I always get

"An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: The remote server returned an error: (404) Not
Found."

I used the example from the documentation verbatim. Is this a LAN/firewall issue possibly? I have tried to download image files which I can see in a
browser.
Function WebClientTest()
Dim remoteUri As String =
"http://www.contoso.com/library/homepage/images/"
Dim fileName As String = "ms-banner.gif"
Dim myStringWebResource As String = Nothing
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
' Concatenate the domain with the Web resource filename. Because
DownloadFile
'requires a fully qualified resource name, concatenate the domain
with the Web resource file name.
myStringWebResource = remoteUri + fileName
Console.WriteLine("Downloading File ""{0}"" from ""{1}"" ......." + ControlChars.Cr + ControlChars.Cr, fileName, myStringWebResource)
' The DownloadFile() method downloads the Web resource and saves it into the current file-system folder.
myWebClient.DownloadFile(myStringWebResource, fileName)
Console.WriteLine("Successfully Downloaded file ""{0}"" from
""{1}""", fileName, myStringWebResource)
Console.WriteLine((ControlChars.Cr + "Downloaded file saved in the
following file system folder:" + ControlChars.Cr + ControlChars.Tab +
Application.StartupPath))
End Function
"Cor" <no*@non.com> wrote in message
news:uR**************@TK2MSFTNGP11.phx.gbl...
Hi Ken,

Why would you do that?

Dim img As Bitmap
Dim wc As New System.Net.WebClient
img = New

Bitmap(wc.OpenRead("http://images.ibsys.com/orlc/images/weather/auto/doppler
_640x480.gif"))

You convert the gif while you can do

webclient.downloadfile("http://images.ibsys.com/orlc/images/weather/auto/dop
pler_640x480.gif")

Cor


Nov 20 '05 #11
Hi,

Maybe they were updating the weather map when you tried it.

Ken
-------------------
"belgie" <be****@hns.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
When I try downloadfile, I always get

"An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: The remote server returned an error: (404) Not
Found."

I used the example from the documentation verbatim. Is this a
LAN/firewall
issue possibly? I have tried to download image files which I can see in a
browser.
Function WebClientTest()
Dim remoteUri As String =
"http://www.contoso.com/library/homepage/images/"
Dim fileName As String = "ms-banner.gif"
Dim myStringWebResource As String = Nothing
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
' Concatenate the domain with the Web resource filename. Because
DownloadFile
'requires a fully qualified resource name, concatenate the domain
with the Web resource file name.
myStringWebResource = remoteUri + fileName
Console.WriteLine("Downloading File ""{0}"" from ""{1}"" ......." +
ControlChars.Cr + ControlChars.Cr, fileName, myStringWebResource)
' The DownloadFile() method downloads the Web resource and saves it
into the current file-system folder.
myWebClient.DownloadFile(myStringWebResource, fileName)
Console.WriteLine("Successfully Downloaded file ""{0}"" from
""{1}""", fileName, myStringWebResource)
Console.WriteLine((ControlChars.Cr + "Downloaded file saved in the
following file system folder:" + ControlChars.Cr + ControlChars.Tab +
Application.StartupPath))
End Function
"Cor" <no*@non.com> wrote in message
news:uR**************@TK2MSFTNGP11.phx.gbl...
Hi Ken,

Why would you do that?
>
> Dim img As Bitmap
> Dim wc As New System.Net.WebClient
> img = New
>

Bitmap(wc.OpenRead("http://images.ibsys.com/orlc/images/weather/auto/doppler
_640x480.gif"))

You convert the gif while you can do

webclient.downloadfile("http://images.ibsys.com/orlc/images/weather/auto/dop
pler_640x480.gif")

Cor


Nov 20 '05 #12

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

Similar topics

2
by: Michael Foord | last post by:
I'm creating a CGI that offers files for download. After googling I though I had the right headers to send to force a download - but it sends the data to the browser instead of opening the download...
1
by: Silvia | last post by:
I have this code in web.config file <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="dllredirect"/> <codeBase...
2
by: Derrick | last post by:
Anyone been able to get a multi file HTTP download working with ASP? I have a single file download working fine with the usual setting the content type, file name, stream the file from...
0
by: Chuck Anderson | last post by:
I am writing a Php script to run on my home PC (Windows) that downloads an Apache access log file and inserts new entries into a database.. The only way I can access these log files is through a...
0
by: Owen Jenkins | last post by:
I've been using Dev's fantastic InetTransferLib to upload and download files via ftp. Now I'm using the http procedures to have my application download zip files from my website. Although the...
1
by: Owen Jenkins | last post by:
Reposting this message from last week since I have not had a reply so far. Hopefully someone will have an idea? --- I've been using Dev's fantastic InetTransferLib to upload and download files...
2
by: Dmitry Duginov | last post by:
I wrote HTTP module and configured it to fire with every request to my application. In IIS6 aspnet_isapi.dll mapped as Application Extension, web.config contains the following: <system.web> ...
4
by: VBTricks.de.vu Webmaster | last post by:
Hello, at the moment I'm not able to finish my program. That means, I have a problem I can't solve myself. Therefore I'm asking those who already worked with HttpWebRequest... and threads. ...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
4
by: rzimerman | last post by:
I'm hoping to write a program that will read any number of urls from stdin (1 per line), download them, and process them. So far my script (below) works well for small numbers of urls. However, it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.