Solved

Retreiving a list of files from a directory

Posted on 2002-06-24
2
146 Views
Last Modified: 2010-05-02
I want to browse a certain directory on a hard drive for a certain file type.
I can do this with the FileListBox (using the Pattern and Path properties) but I want to change the display so the file extension isn't shown.
What I could really do with is an API call that returns a list or windows handles to the files in the directory.

Any ideas?

Thanks,
Andy.
 
0
Comment
Question by:HelpAndy
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 7103425
Use a listbox and the Dir() function:

Private Sub PopFiles(ByVal Pattern As String, ByVal SourcePath As String, ByRef LBox As ListBox)
  Dim strFileName As String
  LBox.Clear
  strFileName = Dir(SourcePath & "\" & Pattern)
  Do While strFileName <> ""
    LBox.AddItem Left(strFileName,Instr(strFilename,".") - 1)
    strFileName = Dir()
  Loop
End Sub

Then call like:

PopFiles "*.txt","c:\Myfolder",List1

To get a list box filled with the filenames minus the extension.
0
 

Author Comment

by:HelpAndy
ID: 7103450
You beauty, thanks Tim.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

757 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

21 Experts available now in Live!

Get 1:1 Help Now