属性
以下代码举例说明如何使用 Attributes 属性:
Sub SetClearArchiveBit(filespec)
Dim fs, f, r
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(fs.GetFileName(filespec))
If f.attributes and 32 Then
r = MsgBox("已设置 Archive 位,是否确定清除?", vbYesNo, "设置/清除 Archive 位")
If r = vbYes Then
f.attributes = f.attributes - 32
MsgBox "已清除 Archive 位。"
Else
MsgBox "保留 Archive 位设置。"
End If
Else
r = MsgBox("未设置 Archive 位。是否确定设置?", vbYesNo, "设置/清除 Archive 位")
If r = vbYes Then
f.attributes = f.attributes + 32
MsgBox "已设置 Archive 位。"
Else
MsgBox "未设置 Archive 位。"
End If
End If
End Sub