|
-
Jul 10th, 2007, 09:29 AM
#1
Thread Starter
New Member
Listing directory content in Visual basic 6
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)
-
Jul 10th, 2007, 09:33 AM
#2
Lively Member
Re: Listing directory content in Visual basic 6
Use FSO, file system objects.
to differentiate file and folder use fso.file and fso.folder...
-
Jul 10th, 2007, 09:35 AM
#3
Re: Listing directory content in Visual basic 6
Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LB_DIR = &H18D
Private Const DDL_DIRECTORY = &H10
Private Const DDL_ARCHIVE = &H20
Private Const DDL_EXCLUSIVE = &H8000
Private Sub Command1_Click()
List1.Clear: List2.Clear
' Directories
SendMessage List1.hwnd, LB_DIR, DDL_EXCLUSIVE Or DDL_DIRECTORY, ByVal "C:\myfolder\*.*"
' Files
SendMessage List2.hwnd, LB_DIR, DDL_EXCLUSIVE Or DDL_ARCHIVE, ByVal "C:\myfolder\*.*"
End Sub
-
Jul 10th, 2007, 09:42 AM
#4
Re: Listing directory content in Visual basic 6
You can also use Dir(), sample available in code bank. Take your pick.
-
Jul 10th, 2007, 09:43 AM
#5
Addicted Member
Re: Listing directory content in Visual basic 6
-
Jul 10th, 2007, 09:44 AM
#6
Thread Starter
New Member
Re: Listing directory content in Visual basic 6
-
Jul 10th, 2007, 09:53 AM
#7
Re: Listing directory content in Visual basic 6
A series of forum sections at the bottom of the main page where members have posted useful code.
Did you try my example?
-
Jul 10th, 2007, 09:53 AM
#8
Re: Listing directory content in Visual basic 6
When you do an advanced search limit your search to the VBForums CodeBank section for Visual Basic 6 by scrolling down the list and selecting it
-
Jul 10th, 2007, 09:54 AM
#9
Re: Listing directory content in Visual basic 6
-
Jul 10th, 2007, 12:07 PM
#10
Thread Starter
New Member
Re: Listing directory content in Visual basic 6
Wow...thanks for all the great help. And Hack, thanks for you code also
CodeBank is really a wonderful virtual bank!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|