|
-
Feb 5th, 2000, 11:23 PM
#1
Thread Starter
Lively Member
How do I "dir" all sub folders and files from a specified root Directory e.g Drive, and add all found files & folders into a Treeview, including Sub Folders ???
Please I really, really, need an example on how to do this.
:-)
-
Feb 6th, 2000, 01:13 AM
#2
-
Feb 6th, 2000, 12:04 PM
#3
Fanatic Member
for all the functions you need to do this add a reference (from project-references) to MS scripting. use the object viewer (F2) to look at the functions. there are lots for file and folder (and properties thereof) manipulation.
email me if you need details
-
Feb 6th, 2000, 12:25 PM
#4
Addicted Member
'Put this in a module:
Public Const MAX_PATH = 259
Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long
Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long
Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long
Public Const FILE_ATTRIBUTE_ARCHIVE = &H20
Public Const FILE_ATTRIBUTE_COMPRESSED = &H800
Public Const FILE_ATTRIBUTE_DIRECTORY = &H10
Public Const FILE_ATTRIBUTE_HIDDEN = &H2
Public Const FILE_ATTRIBUTE_NORMAL = &H80
Public Const FILE_ATTRIBUTE_READONLY = &H1
Public Const FILE_ATTRIBUTE_SYSTEM = &H4
Public Const FILE_ATTRIBUTE_TEMPORARY = &H100
'and this to a form with a listbox on it
Sub GetAllFiles(directory$, mask$)
Dim rec As WIN32_FIND_DATA
Dim filename$
Dim fh&
DoEvents
If Right(directory, 1) <> "\" Then directory = directory & "\"
fh = FindFirstFile(directory & mask, rec)
If fh = 0 Then Exit Sub
Do
filename = Left(rec.cFileName, InStr(rec.cFileName, Chr(0)) - 1)
If (rec.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY Then
If (filename <> ".") And (filename <> "..") Then GetAllFiles directory & filename, mask : List1.additem directory
Else
List1.AddItem directory & filename
End If
Loop While FindNextFile(fh, rec)
FindClose fh
End Sub
------------------
Razzle
ICQ#: 31429438
-
Feb 6th, 2000, 12:48 PM
#5
Thread Starter
Lively Member
Thanks, but what I really wanted was to AddItems to a TREEVIEW with SUBFOLDERS in it, so it creates a directory structure in a TREEVIEW.
Please help. =)
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
|