By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,015 Members | 998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,015 IT Pros & Developers. It's quick & easy.

Transfer time estimate

P: n/a
Hello,
I'm looking for sample code in C# that will estimate the transfer time for a
file between two machines (taking into account bandwidth and latency).
--
Regards,
CF
Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Christophe,

You can't really do that unless you are in the process of sending the
file. The best you can do is make estimates on each side of the process.

When you begin to sending/receive, store the time. As you send/receive
each group of bytes, you take note of the elapsed time (the current time
minus the start time). Divide that by the number of bytes sent/received to
determine how long it takes to send one byte. Then, multiply that ratio by
the number of bytes left, and you will have the approximate time left to
perform the transfer.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Christophe F. [MS]" <ch******@online.microsoft.com> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
Hello,
I'm looking for sample code in C# that will estimate the transfer time for
a file between two machines (taking into account bandwidth and latency).
--
Regards,
CF

Nov 17 '05 #2

P: n/a
Thank you Nicholas, I guess I should not use the File.Copy method to
transfer file then, but file streaming?

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uZ****************@TK2MSFTNGP15.phx.gbl...
Christophe,

You can't really do that unless you are in the process of sending the
file. The best you can do is make estimates on each side of the process.

When you begin to sending/receive, store the time. As you send/receive
each group of bytes, you take note of the elapsed time (the current time
minus the start time). Divide that by the number of bytes sent/received
to determine how long it takes to send one byte. Then, multiply that
ratio by the number of bytes left, and you will have the approximate time
left to perform the transfer.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Christophe F. [MS]" <ch******@online.microsoft.com> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
Hello,
I'm looking for sample code in C# that will estimate the transfer time
for a file between two machines (taking into account bandwidth and
latency).
--
Regards,
CF


Nov 17 '05 #3

P: n/a
Christophe,

If you want to have the ability to perform these calculations as the
copy takes place, then yes.

You might also be able to do the same thing with a call to the
SHFileOperation function through the P/Invoke layer. I believe it will
allow you to specify a callback which is called during the operation.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Christophe F. [MS]" <ch******@online.microsoft.com> wrote in message
news:OS**************@TK2MSFTNGP15.phx.gbl...
Thank you Nicholas, I guess I should not use the File.Copy method to
transfer file then, but file streaming?

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:uZ****************@TK2MSFTNGP15.phx.gbl...
Christophe,

You can't really do that unless you are in the process of sending the
file. The best you can do is make estimates on each side of the process.

When you begin to sending/receive, store the time. As you
send/receive each group of bytes, you take note of the elapsed time (the
current time minus the start time). Divide that by the number of bytes
sent/received to determine how long it takes to send one byte. Then,
multiply that ratio by the number of bytes left, and you will have the
approximate time left to perform the transfer.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Christophe F. [MS]" <ch******@online.microsoft.com> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
Hello,
I'm looking for sample code in C# that will estimate the transfer time
for a file between two machines (taking into account bandwidth and
latency).
--
Regards,
CF



Nov 17 '05 #4

P: n/a
Great, I got this exemple to work:
http://www.thecodeproject.com/csharp/csdoesshell2.asp?
--
--
Cdt,
CF
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP09.phx.gbl...
Christophe,

If you want to have the ability to perform these calculations as the
copy takes place, then yes.

You might also be able to do the same thing with a call to the
SHFileOperation function through the P/Invoke layer. I believe it will
allow you to specify a callback which is called during the operation.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Christophe F. [MS]" <ch******@online.microsoft.com> wrote in message
news:OS**************@TK2MSFTNGP15.phx.gbl...
Thank you Nicholas, I guess I should not use the File.Copy method to
transfer file then, but file streaming?

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:uZ****************@TK2MSFTNGP15.phx.gbl...
Christophe,

You can't really do that unless you are in the process of sending the
file. The best you can do is make estimates on each side of the
process.

When you begin to sending/receive, store the time. As you
send/receive each group of bytes, you take note of the elapsed time (the
current time minus the start time). Divide that by the number of bytes
sent/received to determine how long it takes to send one byte. Then,
multiply that ratio by the number of bytes left, and you will have the
approximate time left to perform the transfer.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Christophe F. [MS]" <ch******@online.microsoft.com> wrote in message
news:e7**************@tk2msftngp13.phx.gbl...
Hello,
I'm looking for sample code in C# that will estimate the transfer time
for a file between two machines (taking into account bandwidth and
latency).
--
Regards,
CF



Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.