Solved

Check if files exist

Posted on 2006-11-07
1
169 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

733 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