views:

268

answers:

1

i am using Webclient to upload data using Async call to a server,

    WebClient webClient = new WebClient();
   webClient.UploadDataAsync(uri , "PUT", buffer, userToken);

i've attached DatauploadProgress and DatauploadCompleted Events to appropriate callback functions

        // Upload Date Progress
        webClient.UploadProgressChanged += new 
        UploadProgressChangedEventHandler(UploadProgressCallback);

      // Upload Date Progress
     void UploadProgressCallback(object sender, UploadProgressChangedEventArgs e)
    {
        // Magic goes here 

    }

i am trying to assign chunck/partial file upload size, to make the Callback Function get called at chosen periodic times.

Note: i know i can use e.BytesSent to read the bytes sent when the callback function gets called, but that's not what i am trying to do.

+2  A: 

You can't define that chunk size, as WebClient doesn't expose any property to handle that.

If you want to control that packet length, you'll need to transfer your file by custom code, i.e., by looping through your desired chunk size and, at server side, to implementa System.Web.IHttpHandler to rebuild your file in correct order.

Rubens Farias
Sadly i don't own the server :( , so my only solution is to accept the fact that my callback function will get called "randomly" ?
Madi D.
I think so... =/
Rubens Farias
+1 for now, will mark answered later on, hoping for a miracle <Joke> (ex: Jon skeet modifying the .net Framework to expose such property :D ) </Joke>.
Madi D.
So, lets pray for Jon.. =)
Rubens Farias