KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm working on a program that searches entire drives for a given file. At the moment, I calculate an MD5 hash for the known file and then scan all files recursively, looking for a match. The only problem is that MD5 is painfully slow on large files. Is there a faster alternative that I can use while retaining a very small probablity of false positives? All code is in C#. Thank you. Update I've read that even MD5 can be pretty quick and that disk I/O should be the limiting factor. That leads me to believe that my code might not be optimal. Are there any problems with this approach? MD5 md5 = MD5.Create(); StringBuilder sb = new StringBuilder(); try { using (FileStream fs = File.Open(fileName, FileMode.Open, FileAccess.Read)) { foreach (byte b in md5.ComputeHash(fs)) sb.Append(b.ToString("X2")); } return sb.ToString(); } catch (Exception) { return ""; }
Tags (comma-separated)
Save Edits
Cancel