-
Feb 25th, 2017, 02:38 AM
#41
New Member
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
-
Jul 15th, 2020, 11:07 AM
#42
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
-
Jul 16th, 2020, 01:37 AM
#43
Lively Member
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.
-
Jul 16th, 2020, 11:51 PM
#44
New Member
Re: VB - List All The Files In A Directory
Last edited by DryBone; Jul 16th, 2020 at 11:58 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|