日期:2008-11-13  浏览次数:21019 次

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' 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.DriveExists
' - FileSystemObject.FolderExists
' - FileSystemObject.GetFolder
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Function GenerateTestInformation(FSO)

    Dim TestFolder
    Dim S

    If Not FSO.DriveExists(TestDrive) Then Exit Function
    If Not FSO.FolderExists(TestFilePath) Then Exit Function

    Set TestFolder = FSO.GetFolder(TestFilePath)

    GenerateTestInformation = GenerateAllFolderInformation(Tes