saving URLs to Files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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/thumbnail.jpg?id=027735501526516

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
 
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
 
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 said:
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 said:
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/thumbnail.jpg?id=027735501526516

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
 

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

Back
Top