Page 2 of 2 FirstFirst 12
Results 41 to 44 of 44

Thread: VB - List All The Files In A Directory

  1. #41
    New Member
    Join Date
    Feb 2017
    Posts
    5

    Re: VB - List All The Files In A Directory

    Dear Paul,

    IF you can help me out it will be great
    actually i am trying to get a code which will work in share drive ,
    to get the list of All Folders Highglited in bold font
    All subfolders if any
    and all type of files
    the last modified date

  2. #42
    Frenzied Member
    Join Date
    Feb 2003
    Posts
    1,807

    Re: VB - List All The Files In A Directory

    Code:
    Option Explicit
    
    Public Declare Function SafeArrayGetDim Lib "oleaut32.dll" (ByRef saArray() As Any) As Long
    
    Public Function GetFiles(Path As String) As String()
    Dim Files() As String
    Dim Item As String
    
       If Not Right$(Path, 1) = "\" Then Path = Path & "\"
       Path = Path & "*.*"
    
       Item = Dir$(Path, vbArchive Or vbHidden Or vbReadOnly Or vbSystem)
       Do Until Item = vbNullString
          If SafeArrayGetDim(Files()) = 0 Then
             ReDim Files(0 To 0) As String
          Else
             ReDim Preserve Files(LBound(Files()) To UBound(Files()) + 1) As String
          End If
    
          Files(UBound(Files())) = Item
          Item = Dir$()
       Loop
    
       If SafeArrayGetDim(Files()) = 0 Then ReDim Files(0 To 0) As String
    
       GetFiles = Files
    End Function
    
    Public Sub Main()
    Dim Item As Variant
    
       For Each Item In GetFiles("C:\Windows\System32")
          Debug.Print Item
       Next Item
    End Sub

  3. #43
    Lively Member
    Join Date
    Sep 2016
    Posts
    94

    Re: VB - List All The Files In A Directory

    There is also 'clsFileAnalyzer v2.5' from NightWolf.
    http://www.planet-source-code.com/vb...67832&lngWId=1
    I use this class on many projects.

  4. #44
    New Member
    Join Date
    Jul 2020
    Posts
    3

    Re: VB - List All The Files In A Directory

    Ooops
    Last edited by DryBone; Jul 16th, 2020 at 11:58 PM.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width