title: WP7 file upload with httpwebrequest and progress indication
body: <p>I am using HttpWebRequest to upload images from a Windows Phone 7 application to a WebDAV Server. The upload is no problem and everything works.
  Now I want to add a progressbar for the file upload. 
  I am using this code to write the data to the stream:</p>
  
  <pre><code>    protected void WriteRequestStream(IAsyncResult result)
      {
  
          Stream stream = (Stream)result.AsyncState;
          Stream streamResponse = httpWebRequest.EndGetRequestStream(result);
  
          byte[] content = new byte[4096];
          long totalBytesRead = 0;
          int bytesRead = 0;
          do
          {
              bytesRead = stream.Read(content, 0, content.Length);
              totalBytesRead += bytesRead;
              streamResponse.Write(content, 0, bytesRead);
              streamResponse.Flush();
  
              if (progressCallback != null)
              {
                  float value = (float)totalBytesRead / stream.Length * 100;
                  progressCallback(value);
              }
          } while (bytesRead &gt; 0);
          streamResponse.Close();
  
  
          httpWebRequest.BeginGetResponse(new AsyncCallback(requestCallback), null);
      }
  </code></pre>
  
  <p>It seems the data I write in the streamResponse object is buffered before it is sent to the WebDAV server. Therefrom the progessbar is to fast and at 100% before the upload is finished.</p>
  
  <p>I noticed there is no AllowWriteStreamBuffering property in the HttpWebRequest class. Is there any solution to upload a file with HttpWebRequest in WP7 and displaying the upload progress?</p>
  
  <p>Thank you!</p>