public static bool Contains(this DocumentCollection docCol, string fileName, out Document document)
{
document = null;
if (string.IsNullOrEmpty(fileName))
return false;
string fn = Path.GetFullPath(fileName);
foreach (Document doc in docCol)
{
if (fileName.EndsWith("dwt", StringComparison.OrdinalIgnoreCase) &&
doc.Name.EndsWith("dwg", StringComparison.OrdinalIgnoreCase)) continue; // у черетежа еще нет имени, а в doc.Database.Filename записано имя шаблона
string docName = doc.Database.Filename;
if (string.IsNullOrEmpty(docName))
continue;
if (fn.Equals(Path.GetFullPath(docName), StringComparison.OrdinalIgnoreCase))
{
document = doc;
return true;
}
}
return false;
}