Log in

View Full Version : Solved: Detect if CD is formatted.



Dave
03-07-2011, 12:40 PM
I'm trying to find some VB code that will differentiate between when a CD drive has no disk vs. a CD drive that has an unformatted disk. Not much luck with the google. This code returns the same result whether there is no CD or an unformatted CD exists. Any help appreciated. Dave


If .Drives(Left(CdDriveLetter, 2)).IsReady = False Then

Dave
03-08-2011, 09:46 PM
With reflection that wasn't all that clear. I messed with it abit and it seems that copyfile yields some detectable error. Humm. Dave

CdDriveLetter = InputBox("Enter a CD directory. CAPITAL LETTER ONLY!")
CdDriveLetter = CdDriveLetter & ":\"
On Error GoTo ErFix
Set OfsObj = CreateObject("Scripting.FilesystemObject")
'check if Drive exists.
With OfsObj
If .Driveexists(Left(CdDriveLetter, 2)) = False Then
MsgBox "You do not have a directory: " & CdDriveLetter
Set OfsObj = Nothing
Exit Sub
End If
End With
Set OfsObj = Nothing

Dave
03-25-2011, 01:36 PM
Didn't find any other solution than this. Solved? Dave

Set FSO = CreateObject("Scripting.FileSystemObject")
'source,destination,save
FSO.CopyFile "c:\source.zip", "c:\destination.zip", True
If Err.Number = -2147024895 Then
MsgBox "The disk is NOT formatted!"
End If