Reputation: 11010
I am comparing two folders for non identical files with symmetric difference and write the length and directory name into a text file...But it is writing like
5506 D:\Trial\codegenpath\ramcovm247_portal_765\EDKPLAjaxCodeGen.log
5857 D:\Trial\codegenpath\ramcovm247_portal_765\EDKService.log
3741 D:\Trial\codegenpath\ramcovm247_portal_765\EDKTypes.log
10644 D:\Trial\zippedpath\ramcovm247_portal_765\EDKPLAjaxCodeGen.log
11714 D:\Trial\zippedpath\ramcovm247_portal_765\EDKService.log
7482 D:\Trial\zippedpath\ramcovm247_portal_765\EDKTypes.log
but i need to write one after other like this
5506 D:\Trial\codegenpath\ramcovm247_portal_765\EDKPLAjaxCodeGen.log
10644 D:\Trial\zippedpath\ramcovm247_portal_765\EDKPLAjaxCodeGen.log
5857 D:\Trial\codegenpath\ramcovm247_portal_765\EDKService.log
11714 D:\Trial\zippedpath\ramcovm247_portal_765\EDKService.log
3741 D:\Trial\codegenpath\ramcovm247_portal_765\EDKTypes.log
7482 D:\Trial\zippedpath\ramcovm247_portal_765\EDKTypes.log
Here is my code
var queryList1Only2 = (from file in list1 select file).Except(list2, myFileCompare1);
var queryList1Only22 = (from file in list2 select file).Except(list1, myFileCompare1);
var difference = queryList1Only2.ToHashSet();
difference.SymmetricExceptWith(queryList1Only22);
foreach (var v in difference )
{
dest.WriteLine(v.Length + " " + v.FullName);
}
and
public class FileCompareLength : System.Collections.Generic.IEqualityComparer<System.IO.FileInfo>
{
public FileCompareLength() { }
public bool Equals(System.IO.FileInfo f1, System.IO.FileInfo f2)
{
return (f1.Length == f2.Length);
}
public int GetHashCode(System.IO.FileInfo fi)
{
string s = String.Format("{0}", fi.Length);
return s.GetHashCode();
}
}
Any suggestion??
Upvotes: 1
Views: 1126