|
| |

Fortgeschrittene Programmierung| Re: Name aller Unterordner | |  | | Autor: RapID23o5 | | Datum: 12.01.06 15:56 |
| Hier ein kleines Bsp.:
Ich habe eine DelTree Funktion geschrieben,
die hier in 'abgeänderter' Form die Verzeichnisse auflistet.
Aufruf:
call ListDirectoryTree("C:\temp\")Einfach alles in ein Modul stecken:
Option Explicit
Private Declare Function PathIsDirectoryEmpty Lib "shlwapi.dll" Alias _
"PathIsDirectoryEmptyA" (ByVal pszPath As String) As Long
Private Declare Function PathIsDirectory Lib "shlwapi.dll" Alias _
"PathIsDirectoryA" (ByVal pszPath As String) As Long
Public Function PathIsDotted(strPath As String) As Boolean
strPath = Trim$(strPath)
If Left$(strPath, 1) = "." Then
PathIsDotted = True
Else
PathIsDotted = False
End If
End Function
Public Function PathRemoveDots(strPath As String) As Long
strPath = Trim$(strPath)
If InStr(1, strPath, ".", 1) <> 0 Then
strPath = Replace$(strPath, ".", "", Compare:=1)
End If
PathRemoveDots = 0
End Function
Public Function PathAddDir(strPath As String, strDir As String) As Boolean
PathAddDir = False
Dim strTMP As String
strPath = Trim$(strPath)
strDir = Trim$(strDir)
If Len(strPath) = 0 Then Exit Function
If Len(strDir) = 0 Then Exit Function
PathAddBackslash strPath
PathAddBackslash strDir
strTMP = strPath & strDir
If PathIsDirectory(strTMP) = vbDirectory Then
strPath = strTMP
PathAddDir = True
End If
End Function
Public Function PathAddBackslash(strPath As String) As Long
strPath = Trim$(strPath)
If Right$(strPath, 1) <> "\" Then
strPath = strPath & "\"
End If
PathAddBackslash = 0
End Function
Public Function ListDirectoryTree(ByVal strPath As String) As Boolean
Dim strPTH As String
Dim strTMP As String
Dim lngLEN As Long
Dim lngRET As Long
ListDirectoryTree = False
strPTH = strPath
lngRET = PathAddBackslash(strPTH)
lngRET = PathIsDirectory(strPTH)
If lngRET <> vbDirectory Then
Exit Function
End If
Dim colXItems As New Collection
Dim colDirItems As New Collection
Dim varItem As Variant
Dim lngCnt As Long
colDirItems.Add strPTH, strPTH
Do Until lngCnt = colDirItems.Count
lngCnt = colDirItems.Count
For Each varItem In colDirItems
strTMP = Dir$(varItem, vbDirectory)
Do Until strTMP = vbNullString
Do While PathIsDotted(strTMP)
strTMP = Dir$
Loop
If strTMP = vbNullString Then
Exit Do
End If
strPTH = varItem
If PathAddDir(strPTH, strTMP) Then
colDirItems.Add strPTH, strPTH
End If
strTMP = Dir$
Loop
colXItems.Add varItem, varItem
colDirItems.Remove varItem
Next varItem
DoEvents
Loop
For Each varItem In colXItems
' hier sind die Pfade
Debug.Print CStr(varItem)
Next varItem
Set colDirItems = Nothing
Set colXItems = Nothing
ListDirectoryTree = True
End Function Hoffe das hilft dir weiter oder gibt wenigstens etwas anregung!
Ohne Mampf, kein Kampf ! |  |
 | Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
  |
|
sevWizard für VB5/6 
Professionelle Assistenten im Handumdrehen
Erstellen Sie eigene Assistenten (Wizards) im Look & Feel von Windows 2000/XP - mit allem Komfort und zwar in Windeseile :-) Weitere InfosTipp des Monats Access-Tools Vol.1 
Über 400 MByte Inhalt
Mehr als 250 Access-Beispiele, 25 Add-Ins und ActiveX-Komponenten, 16 VB-Projekt inkl. Source, mehr als 320 Tipps & Tricks für Access und VB
Nur 24,95 EURWeitere Infos
|
| |
|
Copyright ©2000-2025 vb@rchiv Dieter Otter Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.
Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel
|
|