Solved

Retreiving a list of files from a directory

Posted on 2002-06-24
2
154 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
using Access 8 68
vb6 connector to SQL Server 2 37
VB 6 error 5 in windows 10 but not in XP 7 56
Send outlook email from VBS Script 2 29
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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

773 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