c# LINQ: Filter List of Files based on File Size
问题 I need some help using LINQ to filer a list of files based on the file size. I have some code but it's using file.length instead of FileInfo(file).length. I don't know how to implement an object 'FileInfo' in the expression. HELP? { IEnumerable<string> result = "*.ini,*.log,*.txt" .SelectMany(x => Directory.GetFiles("c:\logs", x, SearchOption.TopDirectoryOnly)) ; result = result .Where(x => (x.Length) > "500000") ; } 回答1: You should be able to do something like this. Using a DirectoryInfo,