tags:

views:

25

answers:

2

I need to implement uploading and downloading files as cheap as possible. For my tests I use Windows XP with IIS 5 and a console C# program.

I created a virtual directory in IIS and in my program I execute the following code:

System.Net.WebClient webClient = new System.Net.WebClient();
webClient.Credentials = System.Net.CredentialCache.DefaultCredentials;
webClient.UploadFile( "http://localhost/Exchange/file.jpg", "PUT", localPathToMyFile );

those lines execute successfully and a file appears in the directory used to serve contents to the virtual directory. The problem is the file contents in surrounded by extra data:

-----------------------8ccfabf2a995855
Content-Disposition: form-data; name="file"; filename="file.jpg"
Content-Type: application/octet-stream
//file contents goes here
-----------------------8ccfabf2a995855

Where does this extra data come from? What do I do so that it doesn't appear, but the file is uploaded as is?

+2  A: 

It's how HTML forms are uploaded.

Explanation: http://www.15seconds.com/issue/001003.htm

Actual specification http://www.faqs.org/rfcs/rfc2388.html

How do you save the files?

jgauffin
+2  A: 

The extra data comes from the HTTP protocol, see here. Try changing the method to "POST" and create aa simple ASP.net webpage that receives and saves the file. Like the example here

corvuscorax