Problem with System.Net.WebClient.OpenWrite

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sven Putze

    Problem with System.Net.WebClient.OpenWrite

    my target:

    I want to upload a file via HTTP Post and show the user a
    progress bar

    my 1st try:

    I´ve used WebClient.Uploa dFile and WebClient.Uploa dData,
    they work fine but I don't know any way to get the actual
    amount of transferred bytes, so what should I show on the
    progressbar?

    my next try:

    Ok, I use WebClient.OpenW rite now (so i can transfer
    little blocks and then show the progress), creating the
    MIME-headers was not that hard and in my home-LAN
    everything seems to work fine.

    my problem:

    When I transfer data to the internet the Write-method
    returns to fast (although it should by synchronous), so I
    send the next block and so on. When the progressbar nearly
    reaches 100% (depending on file size), my program freezes
    and on my Network data is still sent (OK, no wonder that
    sending 2MB over 128kbs upstream doesn't happen in 5
    seconds).
    When the file is small enough, it reaches the website.
    When it's too big I get an exception (some kind of buffer
    overflow I guess).

    my questions:

    why does the write method return still sending data?

    how can I get the Information if data was really sent?

    Is there an asynchronous way to do it?

    Thank you
    regards
    Sven
  • Sven Putze

    #2
    found solution

    Using the class System.Net.WebC lient was not a good idea,
    because it's a buffered stream.
    System.Net.Sock ets.NetworkStre am is a better way of
    dealing with my problem. I must include the HTTP-headers
    and everthings works fine.

    regards
    Sven

    Comment

    Working...