How do I measure the time it takes to copy a file?

  • Thread starter Thread starter Julian Milano
  • Start date Start date
J

Julian Milano

I want to copy a file from one PC to another using DotNet and would like to
time the operation- how do I do it?
 
Julian,
I want to copy a file from one PC to another using DotNet and would like to
time the operation- how do I do it?

On a 1Gb connection or over a 22Kb dataline?

Cor
 
do something like this:

Dim dtMark As DateTime = Now
' do your file copy here
Dim sec As Double = Now.Subtract(dtMark).TotalSeconds
' at this point, sec is double precision seconds that the copy took
 
Julian Milano said:
I want to copy a file from one PC to another using DotNet and would like to
time the operation- how do I do it?

Well, you would have to implement a copy mechanism that calls a
callbackfunction after every nth part of your file has been copied, so you
could gradually improve the estimate of your completion time (a simple
estimating function would be completion time = start time + (elapsed time /
n) * 100)
 
Something like this:

Dim dtStart As DateTime = DateTime.Now

'copy file here

Dim tsElapsed As TimeSpan = DateTime.Now.Subtract(dtStart)

MsgBox("Elapsed time: " & tsElapsed.TotalSeconds.ToString)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top