==============================
JF Software VB Modules
By Joshua Foster - JF Software
http://www.jfsoftware.net
jfsoftware@jfsoftware.net
July 26, 2001
==============================
FileSystemClass class module
============================
Description: A collection of routines for file system interaction.


Directory Procedures:
=====================
-------------
MakeDirectory
-------------
Syntax:       MakeDirectory(strPath As String) As Boolean
Description:  Creates a directory.
Return Value: Returns true if successful, false if an error occured.
Parameters:   strPath - The path of the directory to create.

Example:
--------
Private cFileSys As FileSystemClass  'Define a FileSystemClass object

Private Sub Form_Load()
Set cFileSys = New FileSystemClass  'Load the cFileSys object
'MsgBox the result of a directory create
MsgBox cFileSys.MakeDirectory("C:\MyApp\NewFolder")
End Sub


---------------
RenameDirectory
---------------
Syntax:       RenameDirectory(strFrom As String, strTo As String) As Boolean
Description:  Renames a directory.
Return Value: Returns true if successful, false if an error occured.
Parameters:   strFrom - The path of the original directory.
              strTo   - The path of the new directory.

Example:
--------
'MsgBox the result of a directory rename
MsgBox cFileSys.RenameDirectory("C:\MyApp", "C:\MyNewApp")


---------------
DeleteDirectory
---------------
Syntax:       DeleteDirectory(strPath As String) As Boolean
Description:  Deletes a directory.
Return Value: Returns true if successful, false if an error occured.
Parameters:   strPath - The path of the directory to delete.

Example:
--------
'MsgBox the result of a directory delete.
MsgBox cFileSys.DeleteDirectory("C:\MyApp")



=========================
File Operation Procedures
=========================
--------
CopyFile
--------
Syntax:       CopyFile(strFrom As String, strTo As String, blnOverwrite As Boolean) As Boolean
Description:  Copies a file.
Return Value: Returns true if successful, false if an error occured.
Parameters:   strFrom      - The path of the original file.
              strTo        - The path to copy to.
              blnOverwrite - If true, then if a file exists at strTo, then it will be overwritten.  If false, the file will
                             not be copied.

Example:
--------
'MsgBox the result of an overwrite-enabled copy
MsgBox cFileSys.CopyFile("C:\firstdoc.txt", "C:\MyApp\lastdoc.txt", True)


--------
MoveFile
--------
Syntax:       MoveFile(strFrom As String, strTo As String) As Boolean
Description:  Moves a file (copies and deletes).
Return Value: Returns true if successful, false if an error occured.
Parameters:   strFrom - The path of the original file.
              strTo   - The path to copy to.

Example:
--------
'MsgBox the result of a file move
MsgBox cFileSys.MoveFile("C:\firstdoc.txt", "C:\MyApp\lastdoc.txt")


----------
DeleteFile
----------
Syntax:       DeleteFile(strFile As String) As Boolean
Description:  Deletes a file.
Return Value: Returns true if successful, false if an error occured.
Parameters:   strFile - The path of the file to delete.

Example:
--------
'MsgBox the result of a file delete
MsgBox cFileSys.DeleteFile("C:\MyApp\temp.txt")



=================================
File/Drive Information Procedures
=================================
---------
FindFiles
---------
Syntax:       FindFiles(strPathFilter As String, strRetVals() As String) As Integer
Description:  Finds files of a certain type in a directory.
Return Value: Returns the number of files found.
Parameters:   strPathFilter - The path of the directory to search and the file type to search for.
              strRetVals()  - An array of strings that will receive the file paths.

Example:
--------
'MsgBox the first result of a file find.
Dim temparray() As String
If cFileSys.FindFiles("C:\MyApp\*.*",temparray()) > 0 Then MsgBox temparray(1)


-------------
FindDiskSpace
-------------
Syntax:            FindDiskSpace(strDrive As String)
Description:       Finds the amount of free and total disk space on a drive.
Return Value:      Returns the disk space in the return properties below.
Parameters:        strDrive - The path of the drive to check.
Return Properties: Name:        DriveBytesFreeLong
                   Type:        Long (Read-only)
                   Description: A numerical representation of the number of bytes left on the drive.

                   Name:        DriveBytesTotalLong
                   Type:        Long (Read-only)
                   Description: A numerical representation of the number of bytes total on the drive.

                   Name:        DriveBytesFreeStr
                   Type:        String (Read-only)
                   Description: A string representation of the number of bytes left on the drive.

                   Name:        DriveBytesTotalStr
                   Type:        String (Read-only)
                   Description: A string representation of the number of bytes total on the drive.

Example:
--------
'MsgBox the string result of the amount of total space on drive C:
Call cFileSys.FindDiskSpace("C:\")
MsgBox cFileSys.DriveBytesTotalStr


-------------
FindDriveType
-------------
Syntax:            FindDriveType(strDrive As String) As String
Description:       Finds what type a drive is.
Return Value:      Returns the string of a drive type.  Also returns the drive type in the return properties below.
Parameters:        strDrive - The path of the drive to check.
Types:             Name:        DriveTypeEnum
                   Description: Returns what type a drive is.
                   Members:     DRIVE_NOTEXIST:  The drive doesn't exist
                                DRIVE_REMOVABLE: The drive is a removable drive (3.5" floppy)
                                DRIVE_FIXED:     The drive is a fixed (hard) drive
                                DRIVE_NETWORK:   The drive is a network drive.
                                DRIVE_CDROM:     The drive is a CD-ROM, CD-R, CD-RW, or DVD-ROM drive.
                                DRIVE_RAMDISK:   The drive is a virtual disk.
Return Properties: Name:        DriveTypeDTE
                   Type:        DriveTypeEnum (Read-only)
                   Description: The number of the type of drive. (type DriveTypeEnum)

                   Name:        DriveTypeStr
                   Type:        String (Read-only)
                   Description: A string describing the type of drive.

Example:
--------
'MsgBox the type of drive C:

Call cFileSys.FindDriveType("C:\")
MsgBox cFileSys.DriveTypeStr


---------------
GetSystemDrives
---------------
Syntax:            GetSystemDrives([strDrive As String]) As Boolean
Description:       Finds the status of drive(s).
Return Value:      Returns the status of a specified file (if one is specified).  Also returns an array of drive-existent
                   values in the return property below.
Parameters:        strDrive - The path of the drive to check (optional; if not specified, returns an array of existing drives
                              in the DrivesExistReturn event)
Return Properties: Name:        DriveExists(ByVal drivenum As Long)
                   Type:        Boolean (Read-only)
                   Description: Whether the drive exists or not (drivenum must be between 1 and 26)

Example:
--------
'MsgBox if drive H: exists.
Call cFileSys.GetSystemDrives
MsgBox cFileSys.DriveExists(8)


--------------
GetFileAttribs
--------------
Syntax:            GetFileAttribs(strFile As String)
Description:       Finds the attributes of a file or directory.
Return Value:      Returns the file's attributes in the return properties listed below.
Parameters:        strFile - The path of the file or directory to check.
Return Properties: Name:        FileArchive
                   Type:        Boolean (Read-only)
                   Description: The file/directory's Archive property.

                   Name:        FileCompressed
                   Type:        Boolean (Read-only)
                   Description: The file/directory's Compressed property. (Windows 2000 and ME only)

                   Name:        FileDirectory
                   Type:        Boolean (Read-only)
                   Description: If true, then the file is really a directory.

                   Name:        FileHidden
                   Type:        Boolean (Read-only)
                   Description: The file/directory's Hidden property.

                   Name:        FileReadOnly
                   Type:        Boolean (Read-only)
                   Description: The file/directory's Read-Only property.

                   Name:        FileSystem
                   Type:        Boolean (Read-only)
                   Description: The file/directory's System property.

Example:
--------
'MsgBox the Archive property of a file:
Call cFileSys.GetFileAttribs("C:\tester.txt")
MsgBox cFileSys.FileArchive


--------------
SetFileAttribs
--------------
Syntax:       SetFileAttribs(strFile As String, blnArchive As Boolean, blnHidden As Boolean, blnReadOnly As Boolean, _
              blnSystem As Boolean) As Boolean
Description:  Sets the attributes of a file or directory.
Return Value: Returns true if successful, false if an error occured.
Parameters:   strFile     - The path of the file or directory to change.
              blnArchive  - The file/directory's Archive property.
              blnHidden   - The file/directory's Hidden property.
              blnReadOnly - The file/directory's Read-Only property.
              blnSystem   - The file/directory's System property.

Example:
--------
'Change the all properties of a file to False
Call cFileSys.SetFileAttribs("C:\tester.txt", False, False, False, False)


-----------------
Get83FilePathName
-----------------
Syntax:       Get83FilePathName(strFilePath As String) As String
Description:  Finds the 8.3 format of a file and path name.
Return Value: Returns the 8.3 format of a specified file.
Parameters:   strFilePath - The path of the file to use.

Example:
--------
'MsgBox the 8.3 format of a file.
MsgBox cFileSys.Get83FilePathName("C:\ReallyLongFile.txt")



==============================
Windows Directories Procedures
==============================
------------------
GetSystemDirectory
------------------
Syntax:       GetSystemDirectory() As String
Description:  Finds the path of the System directory (usually, but not always, "C:\Windows\System")
Return Value: Returns the path of the System directory.

Example:
--------
'MsgBox the path of the System directory.
MsgBox cFileSys.GetSystemDirectory


-------------------
GetWindowsDirectory
-------------------
Syntax:       GetWindowsDirectory() As String
Description:  Finds the path of the Windows directory (usually, but not always, "C:\Windows")
Return Value: Returns the path of the Windows directory.

Example:
--------
'MsgBox the path of the Windows directory.
MsgBox cFileSys.GetWindowsDirectory


----------------
GetTempDirectory
----------------
Syntax:       GetTempDirectory() As String
Description:  Finds the path of the Temp directory (usually, but not always, "C:\Windows\Temp")
Return Value: Returns the path of the Temp directory.

Example:
--------
'MsgBox the path of the Temp directory.
MsgBox cFileSys.GetTempDirectory
