c# - 如何查找文件是系统文件还是隐藏文件?

标签 c#

如何判断一个文件是系统文件还是隐藏文件?

例如'C:\File.txt'是否是系统文件。 还有它是否隐藏?

最佳答案

您可以使用 GetAttributes方法:

var att = File.GetAttributes(@"c:\file.txt");
if ((att & FileAttributes.Hidden) == FileAttributes.Hidden) 
{
    // the file is hidden
}

if ((att & FileAttributes.System) == FileAttributes.System)
{
    // the file is system
}

关于c# - 如何查找文件是系统文件还是隐藏文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3486560/

相关文章:

c# - Azure 引用本地路径时出错

c# - 封装在静态类静态属性中Session会不会冲突?

C# 父窗体与子窗体之间的通信

c# - C#中的字符串乘法

c# - 无法加载文件或程序集,PublicKeyToken=null

c# - 如何在WinForms中显示图片然后删除?

c# - 啊!如何在初始化时正确更新 ComboBox 的 SelectedValue?

c# - Visual Studio C# 忽略错误

c# - 创建 AppDomain 并从子文件夹中的程序集调用方法

c# - 以编程方式解锁 Windows