Results 1 to 2 of 2

Thread: File and drive problems

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    18

    Question

    1. How can I check if a directory exists and a file exists?

    2. If I use a drivelist box to set the drive, along with the dirlist box, if I click on afloppy drive), without putting in a floppy it generates an error(because the chdir is related to chdrive)and the program terminates. How can I trap this error to tell the user to put in a floppy in the drive?

  2. #2
    Guest
    #1) Use the Dir() function.
    Code:
    If Dir$("MyFile.txt") <> "" Then 
        'File Exists
    Else
        'File does not exist
    End If
    #2) It's a simple matter of Error Handling.
    Code:
    Private Sub Drive1_Change()
    
        On Error GoTo ERRH
        Dir1 = Drive1
        
    ERRH:
        If Err = 68 Then MsgBox "Drive not ready. Insert disk", vbCritical + vbOKOnly, "Error"
        
    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
  •  



Click Here to Expand Forum to Full Width