Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copying files - .CopyFile vs .ReadAllBytes + WriteAllBytes

Status
Not open for further replies.

mlowe9

Programmer
Apr 3, 2002
221
0
0
US
Doing some Q&D testing...if I copy a file using My.Computer.FileSystem.CopyFile and compare it to copying the same file using a combination of My.Computer.FileSystem.ReadAllBytes and My.Computer.FileSystem.WriteAllBytes, the Read/WriteAllBytes method is significantly faster (more than twice as fast).

Can I assume this is because the .CopyFile does some kind of file integrity checking or something? The speed is quite useful to me, and unless someone can give me a reason NOT to use the Read/WriteAllBytes method..I'm going to use it instead of .CopyFile

My testing:
Code:
My.Computer.FileSystem.CopyFile(sourcefile, destfile, True)
VS.
Code:
temp = My.Computer.FileSystem.ReadAllBytes(sourcefile)
My.Computer.FileSystem.WriteAllBytes(destfile, temp, False)

Thanks for any response.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top