473,472 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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.UploadFile and WebClient.UploadData,
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.OpenWrite 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
Nov 15 '05 #1
1 5476
Using the class System.Net.WebClient was not a good idea,
because it's a buffered stream.
System.Net.Sockets.NetworkStream is a better way of
dealing with my problem. I must include the HTTP-headers
and everthings works fine.

regards
Sven
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Helen Abell | last post by:
Hi, I am trying to use a .Net WebClient object to read data from a url, but I am getting the following error: System.Net.HttpWebRequest.CheckFinalStatus()...
2
by: Max Gattringer | last post by:
Hi, I've got a little problem with the WebClient, I always get a failure while debugging this code: private void menuItem2_Click(object sender, System.EventArgs e) { NameValueCollection...
2
by: xzzy | last post by:
I have .net 1.1 c# . . . . . using System.Net only lists sockets what do I need to do to be able to do: using System.Net.WebClient;
1
by: peter.rietmann | last post by:
I have been suddenly having a performance problem downloading images from one server (productive) to another (productive) using the following code .. WebClient webClient = new WebClient(); try...
5
by: philip | last post by:
Here is some lines of code than I wrote. You can copy/paste theis code as code of form1 in a new project. My problem is this one : I try to write in a file a serie of bytes. BUT some bytes...
1
by: vin.dor | last post by:
Dear All, I am using WebClient in my Visual Studio .Net 2003 project to download an image from the Internet. The following is my function: C# Code: public static bool downloadFile(string...
1
by: Chris Dunaway | last post by:
I am using the following code to test an .aspx page which has no presentation and only a handler for the Page_Load event. I am using this code to POST the contents of an .xml file to the .aspx...
2
by: Amos Soma | last post by:
I am using WebClient to upload a file to a remote server. The call I'm making looks as follows: webClient.UploadFile("http://sdtpcal.someserver.com/Federation/Databases/Federation.Zip",...
1
by: Mike | last post by:
I am using PowerShell to download an XML file into a string using the DownloadString(URI) method of System.Net.WebClient object. Sample commands below: $Result = $Null; $WebClient = new-object...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.