473,624 Members | 2,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2378
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(im ageData);
Bitmap b = new Bitmap(ms);
b.Save(@"c:\goo gle.tiff", ImageFormat.Tif f);
}
catch(WebExcept ion)
{
//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(im ageData);
Bitmap b = new Bitmap(ms);
b.Save(@"c:\goo gle.tiff", ImageFormat.Tif f);
}
catch(WebExcept ion)
{
//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
1813
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 href and src attributes to absolute URLs with this form: href="/somedir/somefile.htm" src="/images/somecategory/image.gif" That way, if you move a page from one directory to another, the links and image references within the page will not...
7
8307
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 curiosity, did a quick scan of an ASCII file of the 542 URLs in my personal bookmark file and discovered exactly 3 that contained commas (two with a single comma, one with three commas) -- so I guess they're pretty rarely used, even if legal. Seems...
0
1346
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) numerous files (actually, one feeds it urls to the various files.) The download includes both a C# Solution for ASP.NET and a CommandLine CSproject. I have 2 questions:
6
1423
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? Also Looking at SQL on and offline. I mean I would like to have a SQL say in
7
1484
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 of URLs an html file is saved. -----begin----- import urllib urlfile = open(r'c:\temp\url.txt', 'r') for lines in urlfile: try:
1
1821
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 single URL and it worked fine. Now when I incorporate an array of URL's, it fails to work. The first "responseFromServer" properly retrieves and displays "http://finance.yahoo.com" (or any other valid URL for the first webrequest.create), but when I...
4
6718
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 code ?? thank you Pedro Leite From Portugal ------------------------------------
9
5092
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
2118
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 links (eg. <a href='<?=$this->baseURL;?>/controller/page/args'>Go somewhere</ a>. But on the CSS / JS files, how will I do it? I wonder, because on the View files, I can do <?=$this->baseURL;?>/css/site.css, and it will work. But images on the...
0
8231
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8168
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8614
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8330
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7153
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.