networking - C# -calculate download/upload time using network bandwidth -
As a feature I'm developing in this application, I need to show the estimated total time / server .
How can the client get the speed of download / upload on the server from the machine
I think if I can be able to get the speed, then I can calculate the time. For - --- 200 MB file = 200 (1024 kb) = 204800 for KB and divide it to 204800 Mb / speed Kb / s = "x" seconds
P> < / Blockquote>
Try something like this:
int chunkSize = 1024; Int sent = 0 Intel total = Reader Long; Date time started = Date time.Now; While (Reader.position & lt; reader.Length) {byte [buffer = new byte [Math. Min (chunk size, reader. Length - reader. Composition)]; ReadBytes = reader.Read (buffer, 0, buffer, lang); // Send sent data packet + = readBytes; Timespane Elapsed Time = DateTime.Now - Started; Estimated Time of TimeSpain = TimeSpain.FormsCand ((Total - Sent) / ((Double) Sent / Expired Time All Sessions)); }
Comments
Post a Comment