以下是一些我修改过并最初从这里复制的代码:
http://msdn.microsoft.com/en-us/library/bb546159.aspx
我正在搜索一个目录的文件名,它的工作正常,但我无法弄清楚如何使它不区分大小写。
错误如下:
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(startFolder);
// This method assumes that the application has discovery permissions
// for all folders under the specified path.
IEnumerable<System.IO.FileInfo> fileList = dir.GetFiles("*.*", System.IO.SearchOption.AllDirectories);
//Create the query
IEnumerable<System.IO.FileInfo> fileQuery =
from file in fileList
where file.Extension == ".pdf"
where file.Name.Contains(searchString, StringComparison.OrdinalIgnoreCase)
orderby file.Name
select file;
这一行包含错误:
where file.Name.Contains(searchString, StringComparison.OrdinalIgnoreCase)
错误如下:
Error 1 'string' does not contain a definition for 'Contains' and the best extension method overload 'System.Linq.ParallelEnumerable.Contains<TSource>(System.Linq.ParallelQuery<TSource>, TSource, System.Collections.Generic.IEqualityComparer<TSource>)' has some invalid arguments C:\Users\k5opjdjc\Documents\Visual Studio 2013\Projects\Test_File_Search\Test_File_Search\Controllers\SearchController.cs 30 23 Test_File_Search
我已经搜索了几个小时,但找不到答案。如果有人能帮忙,我将非常感激。