Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Is FloppyDisk empty?

Hi All,
I am having a bit of trouble writing some code which:
Check if floppy disk is empty?
if true then
..................
else
..............
any thoughts would be appreciated.
[227 byte] By [mp_direct] at [2007-11-11 7:14:39]
# 1 Re: Is FloppyDisk empty?
Use the On Error statement to handle the error that occurs when the drive is empty.
Phil Weber at 2007-11-11 17:27:18 >
# 2 Re: Is FloppyDisk empty?
i think i have not explained it properly,
in my program the user is asked to insert a floppydisk when exporting data.

Before the program exports the txt file to the floppy, i want the program to make sure the floppy disk is empty or else display message box "delete files on disk before export!"

Any thoughts
mp_direct at 2007-11-11 17:28:21 >
# 3 Re: Is FloppyDisk empty?
The easiest method would be to use the Dir function.
pclement at 2007-11-11 17:29:19 >
# 4 Re: Is FloppyDisk empty?
Not sure, i have done this, but keep kettin errors:

Dim retval As String

retval = Dir$("A:\")

If retval.IsEmpty = True Then

MsgBox "disk empty..."

Else

MsgBox "disk full..."

End If

Any thoughts
mp_direct at 2007-11-11 17:30:24 >
# 5 Re: Is FloppyDisk empty?
Rather than If retval.IsEmpty = True, try:

If retval = ""

or

If Len(retval) = 0

Also, you should include a file specification in the Dir() call:

retval = Dir$("a:\*.*")

And if you want to detect directories in addition to files, you should do this:

retval = Dir$("a:\*.*", vbDirectory)
Phil Weber at 2007-11-11 17:31:23 >