-5

I need your help on to calculating the time for copying a file(s) from PC to USB in C#.

Please help.

Thanks in advance.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Harsha
  • 1,861
  • 7
  • 28
  • 56
  • 3
    You've been here for over three years; I would assume that you would know to at least include the relevant code you've tried so far. "I need your help" doesn't tell us anything. – LittleBobbyTables - Au Revoir Sep 05 '13 at 13:48
  • Please be more specific. Are you trying to predict how much time it will take based on the available hardware information? Are you trying to provide a real-time estimate while the file is copying? Are you trying to determine the actual time it took to copy after the copy completed? – J... Sep 05 '13 at 13:56
  • SO Link: http://stackoverflow.com/questions/21880356/calculating-time-remaining-on-file-copy – Harsha Mar 26 '14 at 05:54

1 Answers1

1

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.

Dzmitry Martavoi
  • 6,867
  • 6
  • 38
  • 59