469,570 Members | 1,676 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,570 developers. It's quick & easy.

saving URLs to Files

i have an appliation that, at this stage, uses the HttpWebRequest and
WebResponse objects to get a stream (as a string) on a page on a web site, i
wanted to know, after lookin through the string and grabing the url addresses
on images...ie
http://10.0.0.215/DH/repository/thum...27735501526516

is it possible to save these files as TIF images (on my PC), i have been
lookin through th Filestream classes and, to me, most appear to be set up to
write text based data to files and no save the URL of an image directly

Thanx in advance

Thaynann
Nov 17 '05 #1
2 2241
Hi Thaynann,
The FileStream class will not be able to download from a URL natively.
Probably the simplest way to do this would be something like the following:

string imageUrl = "http://www.google.com/intl/en/images/logo.gif";
byte[] imageData;

WebClient wc = new WebClient();

try
{
imageData = wc.DownloadData(imageUrl);

MemoryStream ms = new MemoryStream(imageData);
Bitmap b = new Bitmap(ms);
b.Save(@"c:\google.tiff", ImageFormat.Tiff);
}
catch(WebException)
{
//something went wrong during the download
}
Hope that helps
Mark R Dawson
http://www.markdawson.org
"Thaynann" wrote:
i have an appliation that, at this stage, uses the HttpWebRequest and
WebResponse objects to get a stream (as a string) on a page on a web site, i
wanted to know, after lookin through the string and grabing the url addresses
on images...ie
http://10.0.0.215/DH/repository/thum...27735501526516

is it possible to save these files as TIF images (on my PC), i have been
lookin through th Filestream classes and, to me, most appear to be set up to
write text based data to files and no save the URL of an image directly

Thanx in advance

Thaynann

Nov 17 '05 #2
thanx for you help, i got it to save the file, unfortantely im gettin the
wrong file, i need to save the image that doesnt represent the thumbnail, but
thanx, that will help me alot
"Mark R. Dawson" wrote:
Hi Thaynann,
The FileStream class will not be able to download from a URL natively.
Probably the simplest way to do this would be something like the following:

string imageUrl = "http://www.google.com/intl/en/images/logo.gif";
byte[] imageData;

WebClient wc = new WebClient();

try
{
imageData = wc.DownloadData(imageUrl);

MemoryStream ms = new MemoryStream(imageData);
Bitmap b = new Bitmap(ms);
b.Save(@"c:\google.tiff", ImageFormat.Tiff);
}
catch(WebException)
{
//something went wrong during the download
}
Hope that helps
Mark R Dawson
http://www.markdawson.org
"Thaynann" wrote:
i have an appliation that, at this stage, uses the HttpWebRequest and
WebResponse objects to get a stream (as a string) on a page on a web site, i
wanted to know, after lookin through the string and grabing the url addresses
on images...ie
http://10.0.0.215/DH/repository/thum...27735501526516

is it possible to save these files as TIF images (on my PC), i have been
lookin through th Filestream classes and, to me, most appear to be set up to
write text based data to files and no save the URL of an image directly

Thanx in advance

Thaynann

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by DM | last post: by
7 posts views Thread by AES | last post: by
6 posts views Thread by MadCrazyNewbie | last post: by
7 posts views Thread by Shani | last post: by
9 posts views Thread by Salve =?iso-8859-1?Q?H=E5kedal?= | last post: by
8 posts views Thread by Bruno Rafael Moreira de Barros | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.