ClassMicrosoft.VisualBasic.FileSystem SyntaxChDrive(drive)
DescriptionThe ChDrive procedure changes the current working (default) disk drive. Usage at a Glance
ExampleThe following example implements one method of testing for a valid drive using the ChDrive procedure. Public Function IsAvailableDrive(newDrive As String) As Boolean ' ----- Check for the existence of a logical drive. Dim currentDrive As String ' ----- Save the current setting. On Error Resume Next currentDrive = Microsoft.VisualBasic.Left(CurDir( ), 1) ' ----- Change to the proposed drive. If an error occurs, ' then assume the drive doesn't exist. Err.Clear( ) ChDrive(newDrive) If (Err.Number = 0) Then IsAvailableDrive = True Else IsAvailableDrive = False End If ' ----- Restore the previous settings. ChDrive(currentDrive) End Function Version Differences
See AlsoChDrive Procedure, CurDir Function |