FileSystemObject 示例代码
时间:2007-12-27 来源:不详 作者:林子
Dim S
S = "Path:" & TabStop & Folder.Path
S = S & NewLine & "Name:" & TabStop & Folder.Name
S = S & NewLine & "Attribs:" & TabStop & ShowFileAttr(Folder)
S = S & NewLine & "Created:" & TabStop & Folder.DateCreated
S = S & NewLine & "Accessed:" & TabStop & Folder.DateLastAccessed
S = S & NewLine & "Modified:" & TabStop & Folder.DateLastModified
S = S & NewLine & "Size:" & TabStop & Folder.Size & NewLine
GenerateFolderInformation = S
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' GenerateAllFolderInformation
'
目的:
'
生成一个字符串,来描述一个文件夹和所有文件及子文件夹的当前状态。
'
示范下面的内容
' - Folder.Path
' - Folder.SubFolders
' - Folders.Count
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function GenerateAllFolderInformation(Folder)
Dim S
Dim SubFolders
Dim SubFolder
Dim Files
Dim File
S = "Folder:" & TabStop & Folder.Path & NewLine & NewLine
Set Files = Folder.Files
If 1 = Files.Count Then
S = S & "There is 1 file" & NewLine
Else
S = S & "There are " & Files.Count & " files" & NewLine
End If
If Files.Count <> 0 Then
For Each File In Files
S = S & GenerateFileInformation(File)
Next
End If
Set SubFolders = Folder.SubFolders
If 1 = SubFolders.Count Then
S = S & NewLine & "There is 1 sub folder" & NewLine & NewLine
Else
S = S & NewLine & "There are " & SubFolders.Count & " sub folders" & NewLine & NewLine
End If
If SubFolders.Count <> 0 Then
For Each SubFolder In SubFolders
S = S & GenerateFolderInformation(SubFolder)
Next
S = S & NewLine
For Each SubFolder In SubFolders
S = S & GenerateAllFolderInformation(SubFolder)
Next
End If
GenerateAllFolderInformation = S
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' GenerateTestInformation
'
目的:
'
生成一个字符串,来描述 C:\Test
文件夹和所有文件及子文件夹的当前状态。
'
示范下面的内容
上一篇:处理文件 下一篇:设计 FileSystemObject
文章评论
共有位Admini5网友发表了评论 查看完整内容