private static void QuickHashFile(DupItem file, int quickHashSize, ref long totalFileBytes, ref long totalReadBytes) { Interlocked.Add(ref totalFileBytes, file.Size); var hashSize = (int)Math.Min(file.Size, quickHashSize); using (var stream = File.Open(file.FileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { file.Tags = new byte[hashSize]; for (var i = 0; i < 3; i++) { var sectionSize = hashSize / 3; long position; if (i == 0) { position = 0; } else if (i == 1) { position = file.Size / 2 - sectionSize / 2; } else { position = file.Size - sectionSize; } stream.Seek(position, SeekOrigin.Begin); stream.Read(file.Tags, i * sectionSize, sectionSize); } file.QuickHash = HashTool.HashBytesText(file.Tags); if (file.Size <= hashSize) { file.Status = CompareStatus.Matched; } Interlocked.Add(ref totalReadBytes, hashSize); } }