473,659 Members | 3,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2930
Maybe you could use the WebClient class.

"Ray Price" <Ra*****@commun ity.nospam> wrote in message
news:ef******** ******@TK2MSFTN GP15.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.WebC lient wc = new System.Net.WebC lient();
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.Crea te(url);
Image img = Image.FromStrea m(wr.GetRespons e().GetResponse Stream());
img.Save("mydow nload.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
2276
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 images, such as: <img src="image.php">. So far, all this works beautifully. Where I'm stuck is that I'd like to keep other web sites from including my image on remote web pages. I want the image to only display when rendered on pages from my web...
2
2672
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 reduce corporate internet traffic). It's demanded to dinamically show the size and the date of creation for each hyperlinked file on this page. I found a solution know how to do it if the files are on the same server - with the "getfile().size"...
5
6049
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 directory to another on the remote server. Reading the postings on these functions they suggest that it can be done but it appears to be the case if your are hosting your site on the same machine you want to copy the files to. Does anyone know if there...
4
2821
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 mechanism. The product is a CD catalog that will be delivered to many customers and they want the ability to log specific pages accross the Internet, and there's no gaurantee these people will be connected to the Internet, the ones that are...
3
315
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. Can anyone shed some light on how to do this? Thanks Ray
3
1491
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 application which needs one tiny little folder icon (e.g. http://us.geo1.yimg.com/pic.geocities.com/img/filemgr/folder.gif). Now I could have a second file of the folder icon, but I would rather only have one text file to distribute (namely,...
17
2910
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 directory on the same server. This is the line of code that I am using: System.IO.File.Copy(sDistinationFolder + "NewOrderTemplate", sDistinationFolder + myDate.Date + "_" + mtxtJobNumber.Text); So, as you can see, I am copying a folder...
2
8037
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 network drive, copying the same files from the same source drive and to the same destination drive, it gives me the following exception: System.Security.SecurityException: Request for the permission of type...
2
2106
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 database is a bunch of locations to images, though instead of a full path it only includes the file name not an absolute path( e.g. image.jpg). Now im trying to copy the names to another database this is no problem but obviously the the images don't...
0
8428
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
8337
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
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8748
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...
0
8628
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
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...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1739
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.