내 파일 검색을 개선 할 방법을 찾고 있습니다. 디렉토리의 모든 파일을 찾는 더 나은 방법
현재 나는이 방법으로 일하고 있어요 :public IEnumerable<FileInfo> FindFilesInDirectory(string dirPath, string searchName)
{
return Directory.Exists(dirPath)
? Directory.GetFiles(dirPath, "*.*", SearchOption.AllDirectories)
.ToList()
.ConvertAll(x => new FileInfo(x))
.Where(x => x.Name.ToLower().Contains(searchName.ToLower()))
: null;
}
이 일을 더 빨리 또는 더 나은 방법이 있나요?
감사
FYI : 파일 이름에만 관심이있는 경우 'FileInfo' 개체를 반환하는 것이 더 많은 오버 헤드입니다. –