|
-
Apr 26th, 2004, 10:33 PM
#1
Thread Starter
Lively Member
Kill File
Hi everyone in vb land!
Hey so I have this code the erases files on a floppy. The problem is when I use this kill file code and the floppy is empty I get an error message “File not found”. Does anyone know how to trap this error or see if the floppy is empty first?
Code: Private Sub Command1_Click()
Kill “A:\*.t”
End Sub
Thanks for any help
reston
-
Apr 26th, 2004, 10:37 PM
#2
Lively Member
Maybe you could use a filelist box and navigate to a:
VB Code:
On Error GoTo a
file1.Path = "A:\"
For i = 0 To File1.ListCount - 1
If Right(File1.List(i), 2) = ".t" Then
'stuff
End If
Next
a:
If Err.Number = 68 Then
MsgBox "No Disk"
End If
-
Apr 26th, 2004, 10:40 PM
#3
Like:
VB Code:
Option Explicit
Private Sub Command1_Click()
If Dir$("A:\*.txt", vbNormal) <> "" Then
'File exists
Kill "A:\*.txt"
End If
End Sub
Edit
Note: If using a wildcard "*" like that, the first file returned will be deleted.
Bruce.
Last edited by Bruce Fox; Apr 26th, 2004 at 10:45 PM.
-
Apr 26th, 2004, 11:02 PM
#4
Thread Starter
Lively Member
Resolved kill file
Thanks you for the help
reston
This is what i'm using
Private Sub Command1_Click()
On Error GoTo a:
ace = 69
If Dir$("A:\*.txt", vbNormal) <> "" Then
'File exists
Kill "A:\*.txt"
End If
a:
If Err.Number = 52 Then
MsgBox "Please insert disc!", vbOKOnly, "Floppy Disc Error"
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|