473,394 Members | 1,811 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.

Copy file from http location

Hi
From within a c# program running on windows 2003 server I need to copy

individual files (mostly .doc, .pdf, .xml) from one web location
(http://... or https//...) to another.
Can someone suggest the best way to do this? Do I use ftp?

John South
Pangbourne UK
www.wherecanwego.com

Apr 26 '06 #1
3 12998
Use the WebClient class
http://msdn2.microsoft.com/en-us/lib...eh(vs.80).aspx DownloadFile
http://msdn2.microsoft.com/en-us/lib...nloadfile.aspx
or DownloadData method.

or the WebRequest/WebResponse classes if you need more control

Cheers,

Greg
"JohnSouth" <Jo**********@gmail.com> wrote in message
news:11*********************@i39g2000cwa.googlegro ups.com...
Hi
From within a c# program running on windows 2003 server I need to copy

individual files (mostly .doc, .pdf, .xml) from one web location
(http://... or https//...) to another.
Can someone suggest the best way to do this? Do I use ftp?

John South
Pangbourne UK
www.wherecanwego.com

Apr 26 '06 #2
JohnSouth wrote:
Hi
From within a c# program running on windows 2003 server I need to copy

individual files (mostly .doc, .pdf, .xml) from one web location
(http://... or https//...) to another.
Can someone suggest the best way to do this? Do I use ftp?

John South
Pangbourne UK
www.wherecanwego.com

Hello John, this should give you the basic idea

string RemoteFolder = @"http://yoursite.com/YourWebFolder/";
string RemoteFile = "yourfile.txt";
string url = RemoteFolder + RemoteFile;
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
StreamReader sr = new
StreamReader(webResponse.GetResponseStream(),Encod ing.ASCII);
string filecontent = sr.ReadToEnd();
StreamWriter sw = new StreamWriter("c:\mynewfile.txt");
sw.Write(filecontent);
sw.Flush();
sw.Close();
sr.Close();
Apr 26 '06 #3
Excellent. That's just what I need.

John South
Pangbourne UK
www.wherecanwego.com

Apr 26 '06 #4

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

Similar topics

0
by: Grey | last post by:
I have a ASP.NET web application which is required to copy file from windows server to Novell Netware server. I have used impersonation to connect to Netware server. The application works fine when...
9
by: MAF | last post by:
Does anyone know why in 2005 I might be getting this error everytime I try and recompile? Error 226 Unable to copy file "obj\Debug\myfile.dll" to "bin\Debug\myfile.dll". The process cannot...
3
by: MAF | last post by:
Does anyone know why in 2005 I might be getting this error everytime I try and recompile? Error 226 Unable to copy file "obj\Debug\myfile.dll" to "bin\Debug\myfile.dll". The process cannot...
5
by: Standist | last post by:
I want install software on PC in my local network. First I want copy file to the PC through default share like c$ or d$ on the PC. Then install the software through wmi. I have the administrator...
9
by: Alan T | last post by:
Is it possible to copy a file from one location to another? eg. from C:\Temp\Document\TestDoc.doc to C:\Deploy\Document\TestDoc.doc
1
by: Hengiccs | last post by:
Dear all, I need to create a ftp program that similar to WinRAR, that allow me to has an option click on right click menu. When i click on that option my ftp program will start run and allow me...
8
by: baker_tony | last post by:
Hi, is there any way of getting details (such as last modified/created date/time) of a file located on the web? E.g I'd like to know when the file "http://www.myWebSite.com/ update.txt" was last...
9
rizwan6feb
by: rizwan6feb | last post by:
Hello everybody. I need help on how to use copy function to copy file from one computer to another ( or any other way i can copy the file). The computers are on a local network.
1
by: Irrigho5 | last post by:
i have the open file function just need help with the copy file function and main Ask for a source filename and a target filename. Then copy the source file to the target file using the...
2
by: foss | last post by:
hi all, I am not able to copy file from a directory in the server to another directory. Here, the source is outside the web root directory and the destination is inside the web root directory. ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...
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
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,...
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...

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.