-3
如何正確使用哪裏過濾EnumerateFiles與屬性?我得到以下錯誤:篩選器屬性文件Directory.EnumerateFiles系統隱藏的重新分析點?
'IEnumerable' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'IEnumerable'
using System;
using System.IO;
using System.Threading;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var list = Directory.EnumerateFiles(@"c:\", "*", SearchOption.AllDirectories).Where(f => !new FileInfo(f).Attributes.HasFlag(FileAttributes.Hidden | FileAttributes.System | FileAttributes.ReparsePoint));
foreach (var dir in list)
{
Console.WriteLine(dir);
Thread.Sleep(10);
}
}
}
}
加上'使用System.Linq的;' – jdphenix
@jdphenix運行的代碼,但它不這樣做我想要什麼。仍然不排除具有屬性系統,隱藏和重新分析點的文件。它仍然顯示c:\ Documents and Settings訪問被拒絕。 – Nichie
可能的[如何使用Directory.EnumerateFiles不包括隱藏和系統文件]的副本(https://stackoverflow.com/questions/34611088/how-to-use-directory-enumeratefiles-excluding-hidden-and-system-files) – wp78de