Attributes 屬性設(shè)置或返回文件或文件夾的屬性?勺x寫或只讀(與屬性有關(guān))。 object.Attributes [=newattributes]
參數(shù)object 必選項(xiàng)。應(yīng)為 File 或 Folder 對(duì)象的名稱。 newattributes 可選項(xiàng)。如果指定此參數(shù),則 newattributes 為指定的 object 的屬性的新值。 設(shè)置newattributes 參數(shù)可為下列設(shè)置之一或下列設(shè)置的合理組合: 常數(shù) | 值 | 描述 |
---|
Normal | 0 | 普通文件。沒(méi)有設(shè)置任何屬性。 | ReadOnly | 1 | 只讀文件?勺x寫。 | Hidden | 2 | 隱藏文件。可讀寫。 | System | 4 | 系統(tǒng)文件?勺x寫。 | Directory | 16 | 文件夾或目錄。只讀。 | Archive | 32 | 上次備份后已更改的文件。可讀寫。 | Alias | 1024 | 鏈接或快捷方式。只讀。 | Compressed | 2048 | 壓縮文件。只讀。 |
說(shuō)明忽略對(duì)只讀屬性(別名,壓縮或目錄)所作的改變. 當(dāng)設(shè)置屬性時(shí),應(yīng)首先閱讀當(dāng)前屬性,然后按要求改變個(gè)別屬性,最后反寫屬性. 以下代碼舉例說(shuō)明如何使用 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 =" 設(shè)置歸檔位。" End If End Function
請(qǐng)參閱DateCreated 屬性 | DateLastAccessed 屬性 | DateLastModified 屬性 | Drive 屬性 | Files 屬性 | IsRootFolder 屬性 | Name 屬性 | ParentFolder 屬性 | Path 屬性 | ShortName 屬性 | ShortPath 屬性 | Size 屬性 | SubFolders 屬性 | Type 屬性 應(yīng)用于:File 對(duì)象 | Folder 對(duì)象 返回首頁(yè) |