複製鏈接
請複製以下鏈接發送給好友

Attributes

鎖定
Attributes屬性設置或返回文件或文件夾的屬性。可讀寫或只讀(與屬性有關)。
object.Attributes [= newattributes]
參數object
必選項。應為 FileFolder 對象的名稱。
中文名
Attributes
屬    性
返回文件或文件夾的屬性。
參    數
object
必選項
應為File或Folder對象名稱

目錄

Attributes定義

newattributes
可選項。如果指定此參數,則 newattributes 為指定的 object 的屬性的新值。
asdf

Attributes合理組合

設置newattributes 參數可為下列設置之一或下列設置的合理組合:
常數
描述
Normal
0
普通文件。沒有設置任何屬性。
ReadOnly
1
只讀文件。可讀寫。
Hidden
2
隱藏文件。可讀寫。
System
4
系統文件。可讀寫。
Directory
16
文件夾或目錄。只讀。
Archive
32
上次備份後已更改的文件。可讀寫。
Alias
1024
鏈接或快捷方式。只讀。
Compressed
2048
壓縮文件。只讀。
説明忽略對只讀屬性(別名,壓縮或目錄)所作的改變.
當設置屬性時,應首先閲讀當前屬性,然後按要求改變個別屬性,最後反寫屬性.
以下代碼舉例説明如何使用 Attributes 屬性:
Function ToggleArchiveBit(filespec)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
If f.attributes and 32 Then
f.attributes = f.attributes - 32
ToggleArchiveBit = "清空歸檔位。"
Else
f.attributes = f.attributes + 32
ToggleArchiveBit = "設置歸檔位。"
End If
End Function