Solved

API to list all files in a directory

Posted on 2001-06-15
5
148 Views
Last Modified: 2010-05-02
I need an example of the api to list all files in a directory.  
0
Comment
Question by:CodeHead
  • 3
5 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6196428
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 0 total points
ID: 6196429
0
 
LVL 3

Expert Comment

by:hkp
ID: 6196510
By using Microsoft Scripting Runtime, you can easily get access to folders and files in folders.

Here is a sample which shows the name of each file in the folder C:\.

Dim objFSO As Scripting.FileSystemObject
Dim objFolder As Folder
Dim objFile As File
Set objFSO = New Scripting.FileSystemObject
Set objFolder = objFSO.GetFolder("C:\")
For Each objFile In objFolder.Files
    MsgBox objFile.Name
Next

Alternately, if you don't want to specify a reference to the "Microsoft Scripting Runtime" DLL, you can use the following:

Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\")
For Each objFile In objFolder.Files
    MsgBox objFile.Name
Next


I'll bet this will work for you.

Cheers
:-)



0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6210418
Thnks for the A grade and for 0 points, too ;)
Cheers
0
 
LVL 1

Author Comment

by:CodeHead
ID: 6210475
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
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…

770 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