S
sturnfie
Hi all,
I am attempting to write a tool that would get (via something of a
stopwatch action) the amount of time it takes to copy a file from a
local disk to a connected USB drive on a Windows XP machine.
When I run this tool, I am getting average speeds that are faster than
what is theoretically possible over a full-speed USB connection (the
disk is enumerated at Full speed, not High Speed).
When I simply drag and drop a file, using the computer clock to
crudely time the transfer, the copy process takes much longer than
what my program would indicate (via returned times), but with times
that are much more realistic than what I am seeing. The files I am
transferring are text files of specific sizes that I generate at
runtime.
So my question, is there some form of asynchronous transferring going
on? Does the CopyTo call in my code below kick out before all the
information in the file is transferred? Are there OS optimizations
that are causing havok? This seems to be the case, so how can I test
for when the file is completely copied over?
I chose to use C# for this, but have been reading on this group that
there are weaknesses in the language when it comes to file
manipulation. Any suggestions for better approaches / language
choices would be appreciated.
Here is a bit of what I am currently doing:
private TimeSpan CopyFile(FileInfo localFile, string destinationPath)
{
// Collect the time when we start
DateTime Start = DateTime.Now;
// Copy the file, with overwrite
localFile.CopyTo(destinationPath, true);
// Collect the time when we finish
DateTime stop = DateTime.Now;
// Find the difference
TimeSpan diff = stop.Subtract(start);
// Return difference
return diff;
}
Thank you in advance for any responses
I am attempting to write a tool that would get (via something of a
stopwatch action) the amount of time it takes to copy a file from a
local disk to a connected USB drive on a Windows XP machine.
When I run this tool, I am getting average speeds that are faster than
what is theoretically possible over a full-speed USB connection (the
disk is enumerated at Full speed, not High Speed).
When I simply drag and drop a file, using the computer clock to
crudely time the transfer, the copy process takes much longer than
what my program would indicate (via returned times), but with times
that are much more realistic than what I am seeing. The files I am
transferring are text files of specific sizes that I generate at
runtime.
So my question, is there some form of asynchronous transferring going
on? Does the CopyTo call in my code below kick out before all the
information in the file is transferred? Are there OS optimizations
that are causing havok? This seems to be the case, so how can I test
for when the file is completely copied over?
I chose to use C# for this, but have been reading on this group that
there are weaknesses in the language when it comes to file
manipulation. Any suggestions for better approaches / language
choices would be appreciated.
Here is a bit of what I am currently doing:
private TimeSpan CopyFile(FileInfo localFile, string destinationPath)
{
// Collect the time when we start
DateTime Start = DateTime.Now;
// Copy the file, with overwrite
localFile.CopyTo(destinationPath, true);
// Collect the time when we finish
DateTime stop = DateTime.Now;
// Find the difference
TimeSpan diff = stop.Subtract(start);
// Return difference
return diff;
}
Thank you in advance for any responses