
Copy directory list to text file
Hm, i would recommend to use the microsoft scripting runtime ( by linking
the Programm to it ... unfortunately I don't know how this is called in VB
English...)
If you manage to do this although I tried to describe it ;) you may work
with the following code :
All that you need beside it is a Listbox, a commandbutton and a drivelist,
but it should be easy tu fix this to suit it to your project.
The Only thing that i should note at the end is, that this Programm does
recurse EVERY subfolder ...
Bye
Wind...
Code :
Option Explicit
Dim FSO As FileSystemObject
Private Sub cmdGO_Click()
Dim sPath As String
List1.Clear
' Init FSO
Set FSO = New FileSystemObject
' Start...
Screen.MousePointer = vbHourglass
sPath = Left$(Drive1.drive, 2)
FSO_GetAllFolders List1, sPath
Screen.MousePointer = vbNormal
End Sub
' Recursive function to get all folders and subfolders
Private Sub FSO_GetAllFolders(Liste As ListBox, _
ByVal sPath As String)
Dim Folder As Folder
Dim SubFolder As Folder
' If possible - add a backslash
If Right$(sPath, 1) <> "\" Then sPath = sPath & "\"
Set Folder = FSO.GetFolder(sPath)
Liste.AddItem sPath
' Ignore a possible Access Error
On Local Error Resume Next
' Read Subfolders
If Folder.SubFolders.Count > 0 Then
For Each SubFolder In Folder.SubFolders
FSO_GetAllFolders Liste, sPath & SubFolder.Name
Next
End If
End Sub