Code: Expanded Class for File Functions

Yesterday I blogged about a simple class to parse file names, and that inspired me to improve it and add some functionality, which will actually come in handy for a project at work shortly.

The class is pretty self-explanatory, there is really nothing complicated in the code.
When the class is initialized, if a path to a directory (i.e. ending with \) is passed to the constructor the directory is created if it does not exist. If the directory exist, there are functions to copy or move both single files or all files in the directory. Directories can also be deleted using the RemoveDir method.
In addition, there are properties to get the path, file name, extension and file size (in bytes) of the file (if the class was initialized with a file name).

Here is an agent with some examples of how to call the class:

Option Public
Option Declare
Use "Class.FileFunctions"
Sub Initialize
Dim file As FileObject
Dim cnt As Integer
Dim success As Boolean
'*** Create new file object
Set file = New FileObject("D:\Downloads\Downloads\MERP\Assassins of Dol Amroth.pdf")
'*** Copy the file to another (new) directory
Call file.CopyTo("D:\Downloads\MERP1\", file.FileName)
'*** Move the file to a new location and replace space with + in file name
Call file.MoveTo("D:\Downloads\MERP2\", Replace(file.FileName," ","+"))
'*** Create a new directory if it does not exist
Set file = New FileObject("D:\Downloads\MERP3\Test\")
'*** Copy all files in specified directory to another directory
Set file = New FileObject("D:\Downloads\Downloads\MERP\")
cnt = file.CopyAllTo("D:\Downloads\MERP\Backup\")
MsgBox "Copied " & cnt & " files."
'*** Move all files in the previously specified directory to another location
cnt = file.MoveAllTo("D:\Downloads\Middle-Earth Role Playing Game\")
MsgBox "Moved " & cnt & " files."
'*** Remove D:\Downloads\Downloads\MERP\
Call file.RemoveDir("")
'*** Remove D:\Downloads\MERP3\ and Test directory that we created earlier
success = file.RemoveDir("D:\Downloads\MERP3\Test\")
If success = True Then
success = file.RemoveDir("D:\Downloads\MERP3\")
If success = False Then
MsgBox "Failed to delete D:\Downloads\MERP3\"
End If
Else
MsgBox "Failed to delete D:\Downloads\MERP3\Test\"
End If
End Sub

Below is the class itself, I put it in a script library called Class.FileFunctions.