|
 |
access thread: Checking a floppy disk
Message #1 by "Clive Astley" <clive.astley@k...> on Wed, 27 Feb 2002 18:40:33
|
|
How can I (a) check that a diskette is in the a:\ drive, (b) that the
diskette is not write protected, and (c) that the floppy is empty (ie no
files exist) please?
Message #2 by "Hamilton, Tom" <hamiltont@s...> on Wed, 27 Feb 2002 11:49:00 -0800
|
|
Hi Clive,
The Dir() function coupled with the GetAttr function should do the trick for
you.
Use DIR("A:\*.*") to verify the floppy and then
GetAttr to view the file attributes which will return a numeric code.
Here's
what I use
Function FileTest(sFile As String) As String ' Find File / Test
attributes
Dim vResult As Variant, iAttrib
On Error GoTo FileError
If Len(sFile & "") = 0 Then
FileTest = "ERROR"
Exit Function
End If
vResult = Dir(sFile)
iAttrib = GetAttr(sFile)
Select Case iAttrib
Case Is = 0
FileTest = "Ok"
Case Is = 1
FileTest = "Read-only"
Case Is = 2
FileTest = "Hidden"
Case Is = 4
FileTest = "System"
Case Is = 16
FileTest = "Directory or Folder"
Case Is = 32
FileTest = "Changed since last backup"
Case Else
FileTest = "ERROR - UNKNOWN FILE STATE"
End Select
FileText_Exit:
Exit Function
FileError:
Beep
Select Case Err.Number
Case Is = 53 ' File not found
FileTest = "File not found => " & sFile & " <="
Resume FileText_Exit
Case Is = 68 ' No Such Disk
FileTest = "No such Drive ID => " & Left(sFile, 1) & ":"
Resume FileText_Exit
Case Is = 71 ' No Disk
FileTest "ERROR - No disk in floppy drive => " & Left(sFile, 1) & ":"
Resume FileText_Exit
Case Else
MsgBox Err.Number & " - " & Err.Description
Resume FileText_Exit
End Select
End Function
>>> Clive Astley 02/27/02 10:40AM >>>
How can I (a) check that a diskette is in the a:\ drive, (b) that the
diskette is not write protected, and (c) that the floppy is empty (ie no
files exist) please?
|
|
 |