Solved

Check if files exist

Posted on 2006-11-07
1
166 Views
Last Modified: 2010-04-30
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
0
Comment
Question by:xizor
1 Comment
 
LVL 14

Accepted Solution

by:
Shiju Sasidharan earned 250 total points
ID: 17888077
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now