我有以下代码,我在“if 语句”中收到一个错误,指出 FileInfo 不包含定义“包含”
哪个是查找文件是否在目录中的最佳解决方案?
谢谢
string filePath = @"C:\Users\";
DirectoryInfo folderRoot = new DirectoryInfo(filePath);
FileInfo[] fileList = folderRoot.GetFiles();
IEnumerable<FileInfo> result = from file in fileList where file.Name == "test.txt" select file;
if (fileList.Contains(result))
{
//dosomething
}