473,394 Members | 1,971 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,394 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 2916
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.