Here's a problem that I've found absolutely no help online or on MSDN with. Maybe someone can shed some light on this subject.
I have an application which downloads files from a web site. Everything works great. I would just like to implement a status label showing the download speed.
Here's the code for downloading the remote file and saving to a local file.
HttpWebResponse resFile = (HttpWebResponse)reqFile.GetResponse();
// Once the WebResponse object has been retrieved,
// get the stream object associated with the response's data
remoteStream = resFile.GetResponseStream();
// Create the local file
localStream = File.Create(locFilName);
// Allocate a 15MB buffer
byte buffer = new byte;
// Simple do/while loop to read from stream until
// no bytes are returned
// Read data (up to 15MB) from the stream
bytesRead = remoteStream.Read(buffer, 0, buffer.Length);
// Write the data to the local file
localStream.Write(buffer, 0, bytesRead);
// Increment total bytes processed
bytesProcessed += bytesRead;
// Update progressbar
this.Invoke(new updProgressDelegate(this.updProgress), 1);
} while (bytesRead > 0);