Check if files exist

I want to check the contents of a folder and find out if ANY files exist with the extension .BAK anyone know a simple way to do this?

Cheers,

Andy
LVL 2
xizorAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Shiju SasidharanConnect With a Mentor Assoc Project ManagerCommented:
place a file list box on your form and try this code

Private Sub Form_Load()
    File1.System = True
    File1.ReadOnly = True
    File1.Hidden = True
    File1.Visible = False
End Sub
Private Sub Command1_Click()
    If FindFile("C:\Your_Folder", "bak") Then  '<----- Change to your folder path
        MsgBox "File found"
    Else
        MsgBox "File not found"
    End If
End Sub
Private Function FindFile(Path As String, Extension As String) As Boolean
    File1.Pattern = "*." & Extension
    File1.Path = Path
    File1.Refresh
    If File1.ListCount > 0 Then FindFile = True
End Function
0
All Courses

From novice to tech pro — start learning today.