設(shè)置或返回文件或文件夾的屬性。根據(jù)不同屬性為讀/寫或只讀。
object.Attributes [= newattributes]
newattributes 參數(shù)可以是下列各值或者這些值的任意邏輯組合:
常數(shù) | 值 | 描述 |
---|---|---|
Normal | 0 | 普通文件。不設(shè)置屬性。 |
ReadOnly | 1 | 只讀文件。屬性為讀/寫。 |
Hidden | 2 | 隱藏文件。屬性為讀/寫。 |
System | 4 | 系統(tǒng)文件。屬性為讀/寫。 |
Volume | 8 | 磁盤驅(qū)動(dòng)器卷標(biāo)。屬性為只讀。 |
Directory | 16 | 文件夾或目錄。屬性為只讀。 |
Archive | 32 | 文件在上次備份后已經(jīng)修改。屬性為讀/寫。 |
Alias | 64 | 鏈接或者快捷方式。屬性為只讀。 |
Compressed | 128 | 壓縮文件。屬性為只讀。 |
下面的代碼通過一個(gè)文件說明了 Attributes 屬性的用法:
[JScript] function ToggleArchiveBit(filespec) { var fso, f, r, s; fso = new ActiveXObject("Scripting.FileSystemObject"); f = fso.GetFile(filespec) if (f.attributes
&& 32) { f.attributes = f.attributes - 32; s = "Archive bit is cleared."; } else { f.attributes = f.attributes + 32; s = "Archive bit is set."; } return(s); } [VBScript] Function ToggleArchiveBit(filespec) Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile(filespec) Iff.attributes
and 32 Then f.attributes = f.attributes - 32 ToggleArchiveBit = "Archive bit is cleared." Else f.attributes = f.attributes + 32 ToggleArchiveBit = "Archive bit is set." End If End Function
DateCreated 屬性 | DateLastAccessed 屬性 | DateLastModified 屬性 | Drive 屬性 | Files 屬性 | IsRootFolder 屬性 | Name 屬性 | ParentFolder 屬性 | Path 屬性 | ShortName 屬性 | ShortPath 屬性 | Size 屬性 | SubFolders 屬性 | Type 屬性
應(yīng)用于:File 對(duì)象 | Folder 對(duì)象