Solved

API to list all files in a directory

Posted on 2001-06-15
5
150 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
[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
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

756 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