p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

pro_vb thread: Resetting All Attributes Within A Given Folder


Message #1 by "Nigel" <nigel.parker@c...> on Wed, 4 Apr 2001 08:54:01
Try using a recursive procedure call.  It is good for looping through tree
structures.  

Here is some sample code.

_____________________________________________
Option Explicit
'References:
'  Microsoft Scripting Runtime

Public Sub LoopThroughFiles(RootFolder As String)
    Dim fs As FileSystemObject
    Dim fld As Folder
    
    Set fs = New FileSystemObject
    
    Set fld = fs.GetFolder(RootFolder)
    
    Call GetFiles(fld)
End Sub

'this is a recursive procedure that will
'loop through the directory you specify
'and any sub folders
Private Sub GetFiles(fld As Folder)
    Dim fldSub As Folder
    Dim fil As File
    
    For Each fldSub In fld.SubFolders
        'if the folder passed in has sub
        'folders, call itself.
        Call GetFiles(fldSub)
    Next
    
    For Each fil In fld.Files
        Debug.Print fld.Path & fil.Name & " | " & fil.Attributes
    Next
End Sub
__________________________________________

Hope it helps.



-----Original Message-----
From: Nigel [mailto:nigel.parker@c...]
Sent: Wednesday, April 04, 2001 1:54 AM
To: professional vb
Subject: [pro_vb] Resetting All Attributes Within A Given Folder


Hi Everyone,

A quick question, I hope...
Does anyone of a quick way to loop through all of the files within a 
folder and its sub foders and clear all of the file attributes no matter 
what file type they are?

Thanks

Nigel


  Return to Index