我正在比较具有对称差异的非相同文件的两个文件夹,并将长度和目录名称写入文本文件......但它写得像
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
但我需要像这样写一个接一个
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
这是我的代码
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);
}
和
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();
}
}
有什么建议吗?