473,385 Members | 1,468 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,385 software developers and data experts.

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 2359
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: DM | last post by:
I'm working on a site with more than 1700 HTML files. We'll be moving files around on this site a lot because we're reorganizing it. I'm thinking of writing a script that will convert all URLs in...
7
by: AES | last post by:
Encountered a URL containing a comma the other day -- the first time I've ever noticed that, so far as I can recall. It worked fine, however, and I gather commas are legal in URLs. Out of...
0
by: pk | last post by:
I'm using SgmlReader (found at http://www.gotdotnet.com/Community/UserSamples/Details.aspx ?SampleGuid=b90fddce-e60d-43f8-a5c4-c3bd760564bc)and I'm trying to make it iterate over (process)...
6
by: MadCrazyNewbie | last post by:
Hey Group, I wounder if somebody could possibly help me a little? Is it possible to store XLS and DOC files into a MSaccess Database, or SQL Database? If so anybody got any links or tips? ...
7
by: Shani | last post by:
I have the following code which takes a list of urls "http://google.com", without the quotes ofcourse, and then saves there source code as a text file. I wan to alter the code so that for the list...
1
by: Hexman | last post by:
Code below ---- I'm trying to save some specific web pages to disk as text files. I searched the Internet and found a basic example which I changed to fit my needs. I tested it out first on a...
4
by: Pedro Leite | last post by:
Good Afternoon. the code below is properly retreiving binary data from a database and saving it. but instead of saving at client machine is saving at the server machine. what is wrong with my...
9
by: Salve =?iso-8859-1?Q?H=E5kedal?= | last post by:
What is the best regular expression for finding urls in plain text files? (By urls I mean http://www.something.com, but also www.something.com, or salve@somewhere.com) Salve
8
by: Bruno Rafael Moreira de Barros | last post by:
I have this framework I'm building in PHP, and it has Search Engine Friendly URLs, with site.com/controller/page/args... And on my View files, I have <?=$this->baseURL;?to print the base URL on the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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...

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.