更新:2007 年 11 月
My.Computer.FileSystem.GetFileInfo 方法可用于获取包含有关指定文件的信息的 FileInfo 对象,包括 FileAttributes 枚举。
确定文件是否为隐藏的
获取要检查的文件的 FileInfo 对象。此示例获取文件 Testfile.txt 的 FileInfo 对象。
Dim infoReader As System.IO.FileInfo infoReader = My.Computer.FileSystem.GetFileInfo("C:\testfile.txt")
从 FileInfo 对象获取 FileAttributes 对象。此示例从 FileInfo 对象获取 FileAttributes 对象。
Dim attributeReader As System.IO.FileAttributes attributeReader = infoReader.Attributes
查询 FileAttributes 以确定文件是否为隐藏的。此示例确定文件是否为隐藏的并显示相应的结果。
If (attributeReader And System.IO.FileAttributes.Hidden) > 0 Then MsgBox("File is hidden!") Else MsgBox("File is not hidden!") End If
请参见
任务
参考
My.Computer.FileSystem.GetFileInfo 方法