使用目录和文件

0 c#

如何在C#4.0中枚举隐藏的文件/目录

基本上我用

var directories = new DirectoryInfo(@"DirectoryName")
                .EnumerateDirectories()
                .Where(**What is the condition that should go here?**)
Run Code Online (Sandbox Code Playgroud)

小智 5

使用 FileAttributes.Hidden

var Directories = new DirectoryInfo(@"DirectoryName")
                .EnumerateDirectories()
                .Where(x => x.Attributes.HasFlag(FileAttributes.Hidden))
                .Select(x => x.Name);
Run Code Online (Sandbox Code Playgroud)