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

Here is some sample code.

Option Explicit
'  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)
    For Each fil In fld.Files
        Debug.Print fld.Path & fil.Name & " | " & fil.Attributes
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?



  Return to Index