tags:

views:

167

answers:

2

If I transfer a file over the internet from computer A to computer B using C# using one of the many ways to do file transfers with .NET, What is the best way to tell if the file on computer A and computer B is the same?

I am thinking that MD5 hashes would be a good way to tell. It seems like that is a widely accepted way to tell. However, I am just double checking to see if there is not a better way out there hidden in the .NET framework.

Thank you Tony

+7  A: 

MD5 is the way to go.

Geo
+3  A: 

CRC32 or Adler32, which are a lot faster then MD5. You should use MD5 if you need to check if file was manipulated with malicious intent. If there is no need to, than it's overkill.

vartec
It depends on the computers involved - I'd expect most of the time to be spent on IO unless you're using really slow processors, so the algorithm used (assuming it only needs to read the data once) shouldn't make much odds.
Jon Skeet
True. But then again, you might want to use that on really busy server...
vartec