FileSystemObject 示例代码
时间:2007-12-27 来源:不详 作者:林子
Function ShowFileAttr(File) ' File
可以是文件或文件夹
Dim S
Dim Attr
Attr = File.Attributes
If Attr = 0 Then
ShowFileAttr = "Normal"
Exit Function
End If
If Attr And FileAttrDirectory Then S = S & "Directory "
If Attr And FileAttrReadOnly Then S = S & "Read-Only "
If Attr And FileAttrHidden Then S = S & "Hidden "
If Attr And FileAttrSystem Then S = S & "System "
If Attr And FileAttrVolume Then S = S & "Volume "
If Attr And FileAttrArchive Then S = S & "Archive "
If Attr And FileAttrAlias Then S = S & "Alias "
If Attr And FileAttrCompressed Then S = S & "Compressed "
ShowFileAttr = S
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' GenerateDriveInformation
'
目的:
'
生成一个字符串,来描述可用驱动器的当前状态。
'
示范下面的内容
' - FileSystemObject.Drives
' - Iterating the Drives collection
' - Drives.Count
' - Drive.AvailableSpace
' - Drive.DriveLetter
' - Drive.DriveType
' - Drive.FileSystem
' - Drive.FreeSpace
' - Drive.IsReady
' - Drive.Path
' - Drive.SerialNumber
' - Drive.ShareName
' - Drive.TotalSize
' - Drive.VolumeName
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GenerateDriveInformation(FSO)
Dim Drives
Dim Drive
Dim S
Set Drives = FSO.Drives
S = "Number of drives:" & TabStop & Drives.Count & NewLine & NewLine
'
构造报告的第一行。
S = S & String(2, TabStop) & "Drive"
S = S & String(3, TabStop) & "File"
S = S & TabStop & "Total"
S = S & TabStop & "Free"
S = S & TabStop & "Available"
S = S & TabStop & "Serial" & NewLine
'
构造报告的第二行。
S = S & "Letter"
S = S & TabStop & "Path"
S = S & TabStop & "Type"
S = S & TabStop & "Ready?"
S = S & TabStop & "Name"
S = S & TabStop & "System"
S = S & TabStop & "Space"
S = S & TabStop & "Space"
S = S & TabStop & "Space"
S = S & TabStop & "Number" & NewLine
'
分隔行。
S = S & String(105, "-") & NewLine
上一篇:处理文件 下一篇:设计 FileSystemObject
文章评论
共有位Admini5网友发表了评论 查看完整内容