Saving a JPG from the web to local disk

J

Jerry Spence1

I have an http command such as http://<ip-Address>/getimage to get a jpg
snapshot image from an IP camera. When I put this into a Web browser it
shows the image OK.

What I would like to go is to build some VB.Net to be able to save this
image to disk. I thought of using a Picturebox as this can show web based
images but saving them to disk becomes rather complicated. Is there any
other way?

-Jerry
 
C

cSharpLess

Jerry Spence1 said:
I have an http command such as http://<ip-Address>/getimage to get a jpg
snapshot image from an IP camera. When I put this into a Web browser it
shows the image OK.

What I would like to go is to build some VB.Net to be able to save this
image to disk. I thought of using a Picturebox as this can show web based
images but saving them to disk becomes rather complicated. Is there any
other way?

Maybe something like

Dim Client As System.Net.WebClient = New System.Net.WebClient()
Client.DownloadFile("http://www.example.com/image.jpg", "c:/image.jpg")


should do. Didn't test it though.
 
H

Herfried K. Wagner [MVP]

Jerry Spence1 said:
I have an http command such as http://<ip-Address>/getimage to get a jpg
snapshot image from an IP camera. When I put this into a Web browser it
shows the image OK.

'WebClient.DownloadFile'.
 
G

gene kelley

I have an http command such as http://<ip-Address>/getimage to get a jpg
snapshot image from an IP camera. When I put this into a Web browser it
shows the image OK.

What I would like to go is to build some VB.Net to be able to save this
image to disk. I thought of using a Picturebox as this can show web based
images but saving them to disk becomes rather complicated. Is there any
other way?

-Jerry
Yet, another option:

My.Computer.Network.DownloadFile("http://SomeDomain/Some.jpg", _
"c:/SomeFolder/Some.jpg")

There are 9 other overrides to this to this to handle such things as
credentials, overwrite etc.

Gene
 
J

Jerry Spence1

gene kelley said:
Yet, another option:

My.Computer.Network.DownloadFile("http://SomeDomain/Some.jpg", _
"c:/SomeFolder/Some.jpg")

There are 9 other overrides to this to this to handle such things as
credentials, overwrite etc.

Gene

I tried this but 'My' wasn't defined. Where does it come from?

-Jerry
 
G

gene kelley

I tried this but 'My' wasn't defined. Where does it come from?

-Jerry

My Namespace >> introduced in VS2005. You must be using an earlier
version.
I'm not familiar with the older versions as to what to use in that
case.

Gene
 
C

Cor Ligthert [MVP]

My Namespace >> introduced in VS2005. You must be using an earlier
version.
I'm not familiar with the older versions as to what to use in that
case.
Have a look at the message from Herfried,

Cor
 
J

Jerry Spence1

My Namespace >> introduced in VS2005. You must be using an earlier
version.
I'm not familiar with the older versions as to what to use in that
case.

Gene

Yes I am. Thanks. Good incentive to upgrade!

-Jerry
 
J

Jerry Spence1

Maybe something like
Thanks for this. Worked a treat. Very useful!

-Jerry
Actually I'm not quite out of problems. I'm getting an error:

"The server committed an HTTP protocol violation"

My exe file is Housekeeper 5.0.exe and I understand I need to produce a file
called Housekeeper 5.0.exe.config containing the following:

<?xml version="1.0" encoding="utf-8"
<configuration>
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
</configuration>

I have placed this in the project folder (is that right?) but I still get
the error message. Do I need to load it or anything, or just leave it in the
folder? Have I done everything right?

-Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top