http (c#)

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Hello,

I am trying to transfer zip file via http - how can I do it in c#?

Thank you!
 
csharpula csharp said:
Hello,

I am trying to transfer zip file via http - how can I do it in c#?

Tranfer from a client to a web server?

var client = new System.Net.WebClient();
client.UploadFile(sUrl, sFilePath);

Note this uses a POST so the web server would need a script on the other end
to recieve and process the file.

More specific instructions require more specific description of the job.
 
What is the difference between :

WebClient client = new WebClient();
client.UploadFile(url,path);

And the option of using:

HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create(httpPath);

for the purpose of uploading zip file to some http location?

Thank you!
 
Hello csharpula,
What is the difference between :

WebClient client = new WebClient();
client.UploadFile(url,path);
And the option of using:

HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create(httpPath);
for the purpose of uploading zip file to some http location?

The second option is used to *download*, not upload a file from that location.
 
Jesse said:
The second option is used to *download*, not upload a file from that
location.

Not necessarily.

(Http)WebRequest is perfectly capable of sending a POST request
that uploads data.

Arne
 
csharpula said:
What is the difference between :

WebClient client = new WebClient();
client.UploadFile(url,path);

And the option of using:

HttpWebRequest myReq =
(HttpWebRequest)WebRequest.Create(httpPath);

for the purpose of uploading zip file to some http location?

WebClient is a very high level class that provides some
convenience methods.

(Http)WebRequest is a more low level class (but still way
above TcpClient) that gives you access to headers and
streams.

Arne
 
Back
Top