![]() |
Web Development »
ASP.NET »
Howto
Intermediate
How to transfer files from one webserver to another webserverBy SaidevKumarAn article which describes how to transfer files from one webserver to another webserver. |
C#, Windows, .NET1.1, ASP.NET, VS.NET2003, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

This article describes about a common requirement of transferring files from one web server to another web server.
When I was working in some project, there was a requirement where I had a web application (http://someserver/someapplication) from where I had to transfer the files to another web server (http://www.someotherserver/someotherapplication). So, I thought why should not I share the same with you all.
Download the WebRequest project and WebRequestReceiver project. Install it in a convenient location, e.g.: c:\inetpub\wwwroot. The ZIP file contains both projects.
This article has two projects:
The application makes use of the WebClient class provided in the .NET framework.
//
// For uploading the file
//
try
{
WebClient oclient = new WebClient();
byte[] responseArray =
oclient.UploadFile(txtURLToSend.Text,"POST",txtFileToSend.Text);
lblStatus.Text =
"Check the file at " + Encoding.ASCII.GetString(responseArray);
}
catch (Exception ex)
{
lblStatus.Text = ex.Message;
}
//
// For downloading the file
//
try
{
WebClient oclient = new WebClient();
oclient.DownloadFile(txtURL.Text,txtFileLocation.Text);
lblStatus.Text = "Check the file at " + txtFileLocation.Text;
}
catch (Exception ex)
{
lblStatus.Text = ex.Message;
}
When I say uploading the file from one web server to another web server, it basically posts the file from one web server to another web server like the way a file from the client side is posted when you use <input type="file">.
This example is useful in places where you have to post files from one web server to another web server.
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 8 Mar 2005 Editor: Smitha Vijayan |
Copyright 2005 by SaidevKumar Everything else Copyright © CodeProject, 1999-2010 Web19 | Advertise on the Code Project |