473,499 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transfer time estimate

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
4 3158
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1542
by: Starx | last post by:
I have a while loop in my program that is going to execute a very large number of loops (well over 100000000). Sometimes this can take quite some time for the computer to process so I'd like the...
13
4354
by: Steve Jorgensen | last post by:
Does this sound familliar to anyone? Regardless of the fact that you have been programming in Access for umpteen years, you still are overly optimistic when it comes to estimating time. The...
9
3422
by: shuisheng | last post by:
Dear All, I have little experience in coding. For a c++ code with 30,000 lines, It is large or small? For two average programmers, usually how long does it take to finish the code? The code...
3
1380
by: topthebookie | last post by:
Good Day, I am a newbie to access. Currently running 2003 version. I have created a clients table with a command button "Schedule Estimate" which goes to my client appointments form. I am...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
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
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5468
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
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
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
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
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
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.