Я использую следующий запрос
var queryList1Only = (from file in list1
select file).Except(list2, myFileCompare);
, а myFileCompare
сравнивает 2 файла на основе имени и длины.
Запрос возвращал результаты, если list1 и list2 были маленькими (скажем, 100 файлов во время тестирования), затем я увеличил list1 до 30000 файлов и list2 до 20000 файлов, и теперь запрос говорит "Function Evaluation Timed Out"
.
Я искал в Интернете и обнаружил, что отладка может вызвать его, поэтому я удалил все точки останова и запустил код, теперь программа просто зависла без вывода queryList1Only
Я пытаюсь распечатать, чтобы проверить это.
EDIT:
Это код для myFileCompare
class FileCompare : System.Collections.Generic.IEqualityComparer<System.IO.FileInfo>
{
public FileCompare() { }
public bool Equals(System.IO.FileInfo f1, System.IO.FileInfo f2)
{
return (f1.Name == f2.Name && f1.Directory.Name == f2.Directory.Name &&
f1.Length == f2.Length);
}
// Return a hash that reflects the comparison criteria. According to the
// rules for IEqualityComparer<T>, if Equals is true, then the hash codes must
// also be equal. Because equality as defined here is a simple value equality, not
// reference identity, it is possible that two or more objects will produce the same
// hash code.
public int GetHashCode(System.IO.FileInfo fi)
{
string s = String.Format("{0}{1}", fi.Name, fi.Length);
return s.GetHashCode();
}
}