public static EnvDTE.Document document(this VisualStudio_2010 visualStudio, string path) { //first search by fullpath var match = (EnvDTE.Document)(from document in visualStudio.documents() where document.FullName == path select document).first(); if (match.notNull()) { return(match); } //then by filename return((EnvDTE.Document)(from document in visualStudio.documents() where document.FullName.fileName() == path select document).first()); }