Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Check if files exist

Posted on 2006-11-07
1
Medium Priority
?
173 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 1000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…
Suggested Courses

609 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