|
-
Oct 2nd, 2000, 09:52 AM
#1
Thread Starter
New Member
Is there any function to count the number of files in a folder except the findfirst, findnext api´s?
-
Oct 2nd, 2000, 10:13 AM
#2
Lively Member
Use Dir
Code:
a = Dir(path)
Do While Len(a)
FileNo = FileNo + 1
a=Dir
Loop
-
Oct 2nd, 2000, 12:24 PM
#3
that bit of code will include other folders as files, so you will get a aflse result in some cases.
Use the FSO to get more reliable results.
-
Oct 2nd, 2000, 12:28 PM
#4
_______
<?>
[code]
'count files in a directory using FileSystemObject
Dim FSO As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FSO = FSO.GetFolder("C:\my documents")
MsgBox FSO.Files.Count
'
'<<<<<<<<<<<<<<<<<<<?>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
'count files in a directory using dir
Dim iFiles As Integer
Dim sDir As String
sDir = Dir("C:\My Documents\*.*", vbNormal + vbHidden + vbArchive + vbReadOnly + vbSystem)
While sDir <> ""
iFiles = iFiles + 1
sDir = Dir
Wend
MsgBox iFiles
[code]
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 3rd, 2000, 02:38 AM
#5
Lively Member
The function i described does not include Directories.
It returns the number of files.
Check it out for yourself.
-
Oct 3rd, 2000, 08:08 AM
#6
Thread Starter
New Member
Thnx!
I´m going to create a component that optimizes the upload of files to a database (file stored in filesystem, path saved in db). It´s says that in order to speed things up you should store 500 files at the most in the same folder. So I don´t have to count all the files in subfolders.
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
|