检查文件是否在 C# 中隐藏


如需检索文件的属性,请使用 FileAttributes 枚举类型。它具有压缩、目录、隐藏等各种成员。

如需检查文件是否隐藏,请使用隐藏成员名称。

如果设置了 FileAttributes.hidden,将表示文件处于隐藏状态。首先,获取路径以查找属性。

FileAttributes attributes = File.GetAttributes(path);

如果设置了以下内容,将表示现在已使用隐藏成员名称隐藏了文件。

 File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);
Console.WriteLine("The {0} file is hidden.", path);

更新于:30-7-2019

788 次查看

开启你 职业生涯

完成课程并获得认证

开始
广告
© . All rights reserved.