Как просмотреть список папок в дирректории?

KV
Дата: 07.06.2004 15:24:55
EDUDK01
Дата: 07.06.2004 15:36:43
From Help:
Sub ShowFolderList(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 in fc
s = s & f1.name
s = s & vbCrLf
Next
MsgBox s
End Sub
KV
Дата: 07.06.2004 15:44:52
Спасибо. Я в хелпе видел этот пример, но не понял что он про subfolder
KV
Дата: 07.06.2004 17:19:22
Почему вот так не хочет работать?

Option Compare Database

Sub ShowFolderList()
Dim fsoFold As Object
Dim fsoSubFold As Object
Dim fold As Folder
Dim subf, fc
'
Dim fl As Folder
Dim fls As Files
Dim f As File
'
fp = CurrentProject.Path
Set fsoFold = CreateObject("Scripting.FileSystemObject")
Set fold = fsoFold.GetFolder(fp)
Set fc = fold.SubFolders

For Each subf In fc
  'Debug.Print subf.Name
  spf = CurrentProject.Path
  Set fl = fsoSubFold.GetFolder(sfp)
  Set fls = fl.Files
    For Each f In fls
     Debug.Print f.Name
    Next
  Next
End Sub

IgorM
Дата: 07.06.2004 18:49:22
А можно еще обычный Dir использовать, это будет универсальнее:
' 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.
    ' Ignore the current directory and the encompassing directory.
    If MyName <> "." And MyName <> ".." Then
        ' Use bitwise comparison to make sure MyName is a directory.
        If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
            Debug.Print MyName    ' Display entry only if it
        End If    ' it represents a directory.
    End If
    MyName = Dir    ' Get next entry.
Loop
KV
Дата: 08.06.2004 10:47:18
А можно таким же макаром, без fso вывести имена файлов входящих в поддирректории?