Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listing directory content in Visual basic 6

Status
Not open for further replies.

jack1080

Programmer
Jun 2, 2007
34
MY
I have a folder called c:\myFolder. Inside the folder has 3 files, which is a.gif, b.gif,c.gif, and a folder called subFolder.

Now given the path C:\myFolder, how do get all the file name or folder name inside? And how to distinguish a folder from a file?
(I only need first level of file name, ie no need to recurse the subfolder)
 

There is an FSO (File System Object) way, but I don't like FSO.

And there is a GUI way:
Place a DirListBox on your Form, set its path to C:\myFolder and it will give you all folders in it.

Place a FileListBox on your Form, set its path to C:\myFolder and it will give you all files in that folder. You may set the Patern (a filter) to show you only certain files with specified extensions, if you want to.

You may step thru these lists to get one at the time.

Would that work for you?



Have fun.

---- Andy
 

Most of the stuff I do with files are pretty simple: Open, Read, Print, Close, etc. So native VB code is just fine for me.

When I need to loop thru files in a folder, I use what I described above - works like a charm.

Or maybe I've never got deep enough into FSO....?
And some people mantioned how slow FSO is.

But - I guess - in many cases is just a personal preference.


Have fun.

---- Andy
 
A quick search turned up these threads:

thread222-1284164
thread222-956222
thread222-856394
thread222-970689

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top