Message 1 of 4
Looping to list subdirectorys

Not applicable
01-28-2002
07:22 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can anyone help me with this problem ??
I am looking for a method to list all files, or drawings in a directory
structure.
I have used the Dir function to return a list of files and folders in a
specified folder, but I need to be able to specify a starting point, then
have the Dir routine list every file and sub folder from that point on !
Am I right in thinking I need to look at putting a loop into this to read
down to the lowest directory first, and if so can you help out with this
please ?
Is it also possible to extract the file owner as well ??????
Many Thanks
Dave
P.S. This is code I am using..
Dim MyFile, MyPath, MyName, MyInfo As String, AllInfo
Open "c:\temp\filesListExp.txt" For Output As #1
' Display the names in C:\ that represent directories.
MyPath = "c:\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
If (GetAttr(MyPath & MyName) And vbfile) = vbfile Then
MyInfo = FileDateTime(MyPath & MyName)
AllInfo = MyPath & MyName & "," & MyName & "," & MyInfo
Write #1, AllInfo ' Display entry only if it
End If ' it represents a directory.
End If
MyName = Dir ' Get next entry.
Loop
I am looking for a method to list all files, or drawings in a directory
structure.
I have used the Dir function to return a list of files and folders in a
specified folder, but I need to be able to specify a starting point, then
have the Dir routine list every file and sub folder from that point on !
Am I right in thinking I need to look at putting a loop into this to read
down to the lowest directory first, and if so can you help out with this
please ?
Is it also possible to extract the file owner as well ??????
Many Thanks
Dave
P.S. This is code I am using..
Dim MyFile, MyPath, MyName, MyInfo As String, AllInfo
Open "c:\temp\filesListExp.txt" For Output As #1
' Display the names in C:\ that represent directories.
MyPath = "c:\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
If (GetAttr(MyPath & MyName) And vbfile) = vbfile Then
MyInfo = FileDateTime(MyPath & MyName)
AllInfo = MyPath & MyName & "," & MyName & "," & MyInfo
Write #1, AllInfo ' Display entry only if it
End If ' it represents a directory.
End If
MyName = Dir ' Get next entry.
Loop