I have an array that contains the path to the files, I want to make a list of files that are duplicated based on their MD5. I calculate their MD5 as follows:
private void calcMD5(Array files) //Array contains a path of all files { int i=0; string[] md5_val = new string[files.Length]; foreach (string file_name in files) { using (var md5 = MD5.Create()) { using (var stream = File.OpenRead(file_name)) { md5_val[i] = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLower(); i += 1; } } } }
From above I can calculate their MD5, but how to get only a list of duplicate files. If there is any other way to do the same, please let me know, and I'm also new to Linq
source share