Uploading/Downloading files


P

Pradeep

Hi All,

Does anyone have any idea of how to upload and download files from server to
client and vice versa in C#.

Thanks
Pradeep
 
Ad

Advertisements

F

Franz

Pradeep said:
Hi All,

Does anyone have any idea of how to upload and download files from server to
client and vice versa in C#.

Thanks
Pradeep
What kind of server you are using?
FTP?
 
P

Pradeep Mareddi

Hi,

The WebServer is IIS6.0. I have Windows2003 Server Operating system.

I am using the following code:

string remoteUri = "http://localhost/UploadFiles/";
string fileName = "Sample.xml", myStringWebResource = null;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();

// Concatenate the domain with the Web resource filename.

myStringWebResource = remoteUri + fileName;
MessageBox.Show("Downloading File \"{0}\" from \"{1}\" .......\n\n" +
fileName+ ", " + myStringWebResource);

// Download the Web resource and save it into the current filesystem
folder.

myWebClient.DownloadFile(myStringWebResource,fileName);

MessageBox.Show("Successfully Downloaded File \"{0}\" from \"{1}\"" +
fileName+ ", " + myStringWebResource);

MessageBox.Show("\nDownloaded file saved in the following file system
folder:\n\t" + Application.StartupPath);

Thanks
Pradeep
 
F

Franz

Pradeep Mareddi said:
Hi,

The WebServer is IIS6.0. I have Windows2003 Server Operating system.

I am using the following code:

string remoteUri = "http://localhost/UploadFiles/";
string fileName = "Sample.xml", myStringWebResource = null;
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();

// Concatenate the domain with the Web resource filename.

myStringWebResource = remoteUri + fileName;
MessageBox.Show("Downloading File \"{0}\" from \"{1}\" .......\n\n" +
fileName+ ", " + myStringWebResource);

// Download the Web resource and save it into the current filesystem
folder.

myWebClient.DownloadFile(myStringWebResource,fileName);

MessageBox.Show("Successfully Downloaded File \"{0}\" from \"{1}\"" +
fileName+ ", " + myStringWebResource);

MessageBox.Show("\nDownloaded file saved in the following file system
folder:\n\t" + Application.StartupPath);
That means you have solved the problem. Am I correct?
 
Ad

Advertisements

P

Pradeep Mareddi

The problem is solved if the directory is under C:\Inetpub\wwwroot. But
if I create a virtual directory, and trying to download the files, I am
getting the Unauthorized exception.

Thanks
Pradeep
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top