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!

How to read Number of Files?

Status
Not open for further replies.

Cap2010

Programmer
Mar 29, 2000
196
CA
HI,

Without any interface, want to read a folder
and to count number of files in a folder.
How do I count number of files in a folder?

Please help.

Cap
 
Check out "FindFirstFile", "FindNextFile" and "FindClose" API calls.

I'm sorry I can give u some examples, because they're stuff I wrote for a client.


Min.
 
Here is some code for you

'Start a new project and add a command button named cmdListFiles
'and then add a reference to the Microsoft Scripting Runtime
Private Sub cmdListFiles_Click()
Dim fso As FileSystemObject
Dim fFile As File
Dim fFolder As Folder

Set fso = New FileSystemObject
Set fFolder = fso.GetFolder(App.Path) 'Open the proper folder path here
Print fFolder.Files.Count

'Clean up the objects
Set fso = Nothing
Set fFile = Nothing
Set fFolder = Nothing
End Sub

Let me know if this helps. If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top