views:

43

answers:

2

I wonder how do I check how much of a file has been uploaded/downloaded? I am using HttpWebRequest

A: 

You have to call it asynchronously to update the progress of your upload/download.

HttpWebRequest have methods like

public override IAsyncResult BeginGetResponse(AsyncCallback callback, object state);
public override IAsyncResult BeginGetRequestStream(AsyncCallback callback, object state);

accepting asynchronous callbacks.

Cheers

Ramesh Vel
downvote?? what for???
Ramesh Vel
Thank you but can you elaborate abit on how you would do this.
jiewmeng
+1  A: 

You can do this is you use async mode on the HttpWebRequest - there is a working sample (based on the MSDN doc sample code) here. Brief description:

Here’s a little Win Forms client that allows you to download a single file from a server, using either HTTP or FTP. It shows download progress and displays the average transfer rate, in kb/sec. It also demonstrates how to use the HttpWebRequest and FtpWebRequest classes in System.Net to do file downloads.

Steve Townsend