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

How to copying image file from remote website to my server?

I want to use a server-side C# script to copy an image from a remote URL to
a local file in the web directory. I tried using File.Copy from the
System.IO namespace but it doesn't support URL.

Can anyone shed some light on how to do this?

Thanks

Ray
Jul 21 '05 #1
3 2909
Maybe you could use the WebClient class.

"Ray Price" <Ra*****@community.nospam> wrote in message
news:ef**************@TK2MSFTNGP15.phx.gbl...
I want to use a server-side C# script to copy an image from a remote URL to a local file in the web directory. I tried using File.Copy from the
System.IO namespace but it doesn't support URL.

Can anyone shed some light on how to do this?

Thanks

Ray

Jul 21 '05 #2
Hi Ray,

As for the retrieving images from remote site via web url address problem,
I think we can choose either the
"WebClient" or "WebRequest" class under the System.Net namespace.

1.The webclient class is a more powerful and encapsulated one, we can use
it to download web resource as below:

string url =
"http://msdn.microsoft.com/library/toolbar/3.0/images/banners/msdn_masthead_
ltr.gif";

System.Net.WebClient wc = new System.Net.WebClient();
wc.DownloadFile(url, "download.gif");

2.The WebRequest class is a bit a raw , since it is often used to retrieve
web content as stream(such as search engine or web spider). We can use the
WebRequest together with the Image class to download a remote image. For
example:

WebRequest wr = WebRequest.Create(url);
Image img = Image.FromStream(wr.GetResponse().GetResponseStrea m());
img.Save("mydownload.gif");

Hope these help. thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 21 '05 #3
Hi Ray,

Have you had a chance to check the suggestions in the former messages or
have you got the problem resolved? If there are anything else we can help,
please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ywg | last post by:
I'm generating an image using several PHP image routines: imagecreatefromjpeg, imagejpeg, etc. The PHP file containing these routines is meant to be included on web pages just like regular...
2
by: Konstantin Mironov | last post by:
Hi all! We have the corporate website based on MS IIS 5.0. There's an ASP page for our customers with the hyperlinks to downloadable files that are hosted on external web server (in order to...
5
by: Ian Davies | last post by:
Hello I am trying to use php to automate the copying of a file from my remotely hosted directory to my computer. I have put together the following but it will only do the copying from one...
4
by: malcolm | last post by:
I've seen several posts around the Internet and many of them either don't work or only partially work. All I'm trying to do is record some action asynchronously from an html file, a sort of logging...
3
by: Ray Price | last post by:
I want to use a server-side C# script to copy an image from a remote URL to a local file in the web directory. I tried using File.Copy from the System.IO namespace but it doesn't support URL. ...
3
by: Csaba Gabor | last post by:
Not sure of best place for this question... Are there any built in images within the browser that I can assume (particularly IE and FF)? More specifically, I am writing a one file webApp.php...
17
by: Michael | last post by:
Hello, I am writing an app that will sit on the desktop. It needs to be able to make a copy of a folder that sits on the server. It will copy the folder from the server and place it in the same...
2
by: Jerad Rose | last post by:
I have a fairly simple C# console app which copies files from a network folder to a local folder. When the app resides on my local C: drive, it runs just fine. However, when the app resides on a...
2
by: chazzy69 | last post by:
This is a little hard to explain but i will try to make it as clear as possible. Firstly here's the setup, 2 databases on 2 different servers (databases are identical) now within the first...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.