使用目录和文件

时间:2013-06-23 18:10:09

标签: c#

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

基本上我用

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

1 个答案:

答案 0 :(得分:5)

使用FileAttributes.Hidden

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