fso| example ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' "" "" "" "" "" "" "" "" "" "" "" ""
'
' Generateallfolderinformation
'
Objective
'
' Generates a string that describes the current state of a folder and all files and subfolders.
'
' Demonstrate the content below
'
'-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
'
Objective
'
' Generates a string that describes the current state of the C:\Test folder and all files and subfolders.
'
' Demonstrate the content below
'
'-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 (TestFolder)
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
' Deletetestdirectory
'
Objective
'
' Clean up the test directory.
'
' Demonstrate the content below
'
'-Filesystemobject.getfolder
'-Filesystemobject.deletefile
'-Filesystemobject.deletefolder
'-Folder.Delete
'-File.delete
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub deletetestdirectory (FSO)
Dim TestFolder
Dim subfolder
Dim File
' There are two ways to delete a file:
Fso. DeleteFile (Testfilepath & "\beatles\octopusgarden.txt")
Set File = FSO. GetFile (Testfilepath & "\beatles\bathroomwindow.txt")
File.delete &