判断方法:
DirectoryInfo di = new DirectoryInfo(path);
if ((di.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
{
//为隐藏的
}
在目录信息的对象di中,成员变量attributes将目录的属性存储在每一位上,通过按位与的方法可以去除任何一位。
同理可以判断目录是否为只读(ReadOnly)或者系统(System)等其他属性。