返回一个集合或 Dictionary 对象包含的项目数。只读。
object.Count
object 可以是“应用于”列表中列出的任何集合或对象的名称。
以下代码举例说明如何使用 Count 属性:
Function ShowKeys Dim a, d, i, s '创建一些变量。Set d = CreateObject("Scripting.Dictionary")d.Add "a", "Athens" '添加一些键和项目。d.Add "b", "Belgrade"d.Add "c", "Cairo"a = d.Keys '获取键。For i = 0 To d.Count -1 '重复数组。s = s & a(i) & "<BR>" '创建返回字符串。NextShowKeys = sEnd Function
CompareMode 属性 | Item 属性 | Key 属性
应用于:Dictionary 对象 | Drives 集合 | Files 集合 | Folders 集合 | Matches 集合
返回指定的文件或文件夹的创建日期和时间。只读。
object.DateCreated
object 应为 File 或 Folder 对象的名称。
以下代码举例说明如何使用 DateCreated 属性:
Function ShowFileInfo(filespec) Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile(filespec) ShowFileInfo = "创建:" & f.DateCreatedEnd Function
Attributes 属性 | DateLastAccessed 属性 | DateLastModified 属性 | Drive 属性 | Files 属性 | IsRootFolder 属性 | Name 属性 | ParentFolder 属性 | Path 属性 | ShortName 属性 | ShortPath 属性 | Size 属性 | SubFolders 属性 | Type 属性
应用于:File 对象 | Folder 对象
返回指定的文件或文件夹的上次访问日期和时间。只读。
object.DateLastAccessed
object 应为 File 或 Folder 对象的名称。
以下代码举例说明如何使用 DateLastAccessed 属性:
Function ShowFileAccessInfo(filespec) Dim fso, f, s Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile(filespec) s = UCase(filespec) & "<BR>" s = s & "创建:" & f.DateCreated & "<BR>"s = s & "最后一次访问:" & f.DateLastAccessed & "<BR>"s = s & "最后一次修改:" & f.DateLastModifiedShowFileAccessInfo = sEnd Function
重点 此属性依赖于操作系统的行为。如果操作系统不支持提供时间信息,则 DateLastAccessed 属性不返回任何值。
Attributes 属性 | DateCreated 属性 | DateLastModified 属性 | Drive 属性 | Files 属性 | IsRootFolder 属性 | Name 属性 | ParentFolder 属性 | Path 属性 | ShortName 属性 | ShortPath 属性 | Size 属性 | SubFolders 属性 | Type 属性
应用于:File 对象 | Folder 对象
返回指定的文件或文件夹的上次修改日期和时间。只读。
object.DateLastModified
object 应为 File 或 Folder 对象的名称。
以下代码举例说明如何使用 DateLastModified 属性:
Function ShowFileAccessInfo(filespec) Dim fso, f, s Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile(filespec) s = UCase(filespec) & "<BR>" s = s & "创建时间:" & f.DateCreated & "<BR>"s = s & "上次访问时间:" & f.DateLastAccessed & "<BR>"s = s & "上次修改时间:" & f.DateLastModifiedShowFileAccessInfo = sEnd Function
Attributes 属性 | DateCreated 属性 | DateLastAccessed 属性 | Drive 属性 | Files 属性 | IsRootFolder 属性 | Name 属性 | ParentFolder 属性 | Path 属性 | ShortName 属性 | ShortPath 属性 | Size 属性 | SubFolders 属性 | Type 属性
应用于:File 对象 | Folder 对象
返回指定的文件或文件夹所在的驱动器的驱动器号。只读。
object.Drive
object 应为 File 或 Folder 对象的名称。
以下代码举例说明如何使用 Drive 属性:
Function ShowFileAccessInfo(filespec) Dim fso, f, s Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile(filespec) s = f.Name & "位于驱动器" & UCase(f.Drive) & "<BR>"s = s & "创建时间:" & f.DateCreated & "<BR>"s = s & "上次访问时间:" & f.DateLastAccessed & "<BR>"s = s & "上次修改时间:" & f.DateLastModifiedShowFileAccessInfo = sEnd Function
Attributes 属性 | DateCreated 属性 | DateLastAccessed 属性 | DateLastModified 属性 | Files 属性 | IsRootFolder 属性 | Name 属性 | ParentFolder 属性 | Path 属性 | ShortName 属性 | ShortPath 属性 | Size 属性 | SubFolders 属性 | Type 属性
应用于:File 对象 | Folder 对象
返回本地驱动器或网络共享的驱动器号。只读。
object.DriveLetter
object 应为 Drive 对象的名称。
如果指定的驱动器没有与驱动器号相关联(例如,一个网络共享未映射驱动器号),则 DriveLetter 属性返回零长度字符串 ("")。
以下代码举例说明如何使用 DriveLetter 属性:
Function ShowDriveLetter(drvPath)
Dim fso, d, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set d = fso.GetDrive(fso.GetDriveName(drvPath))
s = "Drive " & d.DriveLetter & ": - "
s = s & d.VolumeName & "<BR>"
s = s & "Free Space: " & FormatNumber(d.FreeSpace/1024, 0)
s = s & " Kbytes"
ShowDriveLetter = s
End Function
AvailableSpace 属性 | DriveType 属性 | FileSystem 属性 | FreeSpace 属性 | IsReady 属性 | Path 属性 | RootFolder 属性 | SerialNumber 属性 | ShareName 属性 | TotalSize 属性 | VolumeName 属性
应用于:Drive 对象
返回由本地机器上所有 Drive 对象组成的 Drives 集合。
object.Drives
object 应为 FileSystemObject 对象的名称。
无论是否插入媒体,可移动媒体驱动器都显示在 Drives 集合中。
您可以使用 For Each...Next 结构枚举 Drives 集合的成员,如下例所示:
Function ShowDriveList Dim fso, d, dc, s, n Set fso = CreateObject("Scripting.FileSystemObject") Set dc = fso.DrivesFor Each d in dcn = ""s = s & d.DriveLetter & " - "If d.DriveType = 3 Thenn = d.ShareNameElseIf d.IsReady Thenn = d.VolumeNameEnd Ifs = s & n & "<BR>"NextShowDriveList = sEnd Function
Drives 集合 | Files 属性 | SubFolders 属性
应用于:FileSystemObject 对象
返回一个描述指定驱动器的类型的值。
object.DriveType
object 应为 Drive 对象的名称。
以下代码举例说明如何使用 DriveType 属性:
Function ShowDriveType(drvpath) Dim fso, d, t Set fso = CreateObject("Scripting.FileSystemObject") Set d = fso.GetDrive(drvpath) Select Case d.DriveType Case 0: t = "未知"Case 1: t = "可移动"Case 2: t = "固定"Case 3: t = "网络"Case 4: t = "CD-ROM"Case 5: t = "RAM磁盘"End SelectShowDriveType = "驱动器" & d.DriveLetter & ": - " & tEnd Function
AvailableSpace 属性 | DriveLetter 属性 | FileSystem 属性 | FreeSpace 属性 | IsReady 属性 | Path 属性 | RootFolder 属性 | SerialNumber 属性 | ShareName 属性 | TotalSize 属性 | VolumeName 属性
应用于:Drive 对象
返回由指定文件夹中所有 File 对象(包括隐藏文件和系统文件)组成的 Files 集合。
object.Files
object 应为 Folder 对象的名称。
以下代码举例说明如何使用 Files 属性:
Function ShowFileList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name
s = s & "<BR>"
Next
ShowFileList = s
End Function
Attributes 属性 | DateCreated 属性 | DateLastAccessed 属性 | DateLastModified 属性 | Drives 属性 | IsRootFolder 属性 | Name 属性 | ParentFolder 属性 | Path 属性 | ShortName 属性 | ShortPath 属性 | Size 属性 | SubFolders 属性 | Type 属性
应用于:Folder 对象
返回由指定文件夹中所有 File 对象(包括隐藏文件和系统文件)组成的 Files 集合。
object.Files
object 应为 Folder 对象的名称。
以下代码举例说明如何使用 Files 属性:
Function ShowFileList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name
s = s & "<BR>"
Next
ShowFileList = s
End Function
Attributes 属性 | DateCreated 属性 | DateLastAccessed 属性 | DateLastModified 属性 | Drives 属性 | IsRootFolder 属性 | Name 属性 | ParentFolder 属性 | Path 属性 | ShortName 属性 | ShortPath 属性 | Size 属性 | SubFolders 属性 | Type 属性
应用于:Folder 对象