EziData Solutions

Web, NET and SQL Server

Getting Information about your Drives

As you have no doubt discovered as you carefully analysed the Scripting library in the Object Browser, there are far more items listed than just the TextStream class and the OpenTextFile method. Using the FileSystemObject you can retrieve a wealth of information about the current computer, including information about available drives, folders and files.

You may on occasion need to display a list of drives the current computer user has access to, so that you can store information about the location of various files used within your Access database. This is very easy using the Drives property of the FileSystemObject.

'declare the variables for use with the Scripting library

Dim fso As New Scripting.FileSystemObject
Dim drvs As Scripting.Drives
Dim drv As Scripting.Drive

'get the drives from fso
Set drvs = fso.Drives

'iterate through the drives and display some data
For Each drv In drvs

Debug.Print drv.DriveLetter & " " & drv.ShareName

Next

You will notice that there is a myriad of properties that you can discover about each Drive, including AvailableSpace and FileSystem, such as FAT and NTSC. Try a few out in the Debug line for the example above and then impress you friends!

Posted: Oct 07 2006, 10:25 by CameronM | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Access | VBA