I need a better solution for handling unready drives and want to be able to see and change files in my rw-drive. Unfortunately it always gives drive unready error and the only thing that I can do is handle the error.
So far I’ve done this:
My Drive:
Private Sub imperialdrive_Change()
On Error GoTo I_have_a_baad_feeling_about_this
imperialdir.Path = RootPathOnDrive(imperialdrive.Drive)
Exit Sub
I_have_a_baad_feeling_about_this:
If Err.Number = 68 Then
MsgBox "The selected drive is not available at the moment.", vbOKOnly, "I feel a disturbance in the force."
Else
MsgBox Err.Number & " " & Err.Description, vbCritical, "There is a Bounty Hunter here."
End If
End Sub
My Function:
'Such a bad choise for a function name
'It sounds like doing smt more than changing the name of drive lol
Public Function RootPathOnDrive(ByVal Drive)
'So how it comes as "k:" instead of "k:\" Is it really cause its not ready? Both ways i should try reaching "k:\"
RootPathOnDrive = Left(Drive, 1) & ":\"
End Function
Have you looked into using the FileSystemObject that is part of the Microsoft Scripting Runtime (scrrun.dll)?
You will need to include the Microsoft Scripting Runtime in your project references, but I have found the FileSystemObject to be invaluable when working with drives and paths.