vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
sevDataGrid - Gönnen Sie Ihrem SQL-Kommando diesen krönenden Abschluß!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

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 !

alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Name aller Unterordner803Tupo1312.01.06 12:06
Re: Name aller Unterordner398Erdmännchen12.01.06 13:14
Re: Name aller Unterordner439vbtricks12.01.06 14:09
Re: Name aller Unterordner422Tupo1312.01.06 14:17
Re: Name aller Unterordner389RalfU12.01.06 14:40
Re: Name aller Unterordner538RapID23o512.01.06 15:56

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

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

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