FileSystemObject.GetDrive Method (VB6) |
oFileSysObj.GetDrive(drivespecifier)
oFileSysObj
Use: Required
Data Type: FileSystemObject object
Any object variable returning a FileSystemObject object.
drivespecifier
Use: Required
Data Type: String
A drive name, share name, or network path.
A Drive object.
Obtains a reference to a Drive object for the specified drive.
If drivespecifier is a share name or network path, GetDrive ensures that it exists as part of the process of creating the Drive object; if it doesn't, the method generates runtime error 76, "Path not found."
If the specified drive isn't connected or doesn't exist, runtime error 67, "Device unavailable," occurs.
If you are deriving the drivespecifier string from a path, you should first use GetAbsolutePathName to insure that a drive is present as part of the path; then you should use FolderExists to verify that the path is valid before calling GetDriveName to extract the drive from the fully qualified path. For example:
Dim oFileSys As New FileSystemObject Dim oDrive As Drive sPath = oFileSys.GetAbsolutePathName(sPath) If oFileSys.FolderExists(sPath) Then Set oDrive = _ oFileSys.GetDrive(oFileSys.GetDriveName(sPath)) End If
If drivespecifier is a network drive or share, you should use the DriveExists method to confirm the required drive is available prior to calling the GetDrive method.
You must use the Set statement to assign the Drive object to a local object variable.