|
-
Oct 6th, 2002, 06:57 AM
#1
Thread Starter
Member
Recursive serach
How can i search recursive through directories for files with a specified extention ?
-
Oct 6th, 2002, 09:01 AM
#2
Hyperactive Member
Well you would start with a root directory and pass it to a procedure:-
'some example prohibitive string variables
dim PrivateFiles as string
dim AllowedExtensions as string
dim PrivateFolders as string
'these strings are for readability comma delimited with
'specific extensions, files, folders etc.
'you could have a privateextensions string too
'e.g.
AllowedExtensions = ".txt,.doc,.asp,.aspx"
PrivateFiles = "private.dll,private.doc,private.asp"
PrivateFolder = "bin,windows,private"
dim Files as new arraylist
GetAllFiles("c:")
Sub GetAllFiles(ByVal RootFolder as string)
dim FileName as string
for each FileName in System.IO.Directory.GetFiles(RootFolder)
dim FInfo as new System.IO.FileInfo(FileName)
if AllowedExtensions.IndexOf("." & FInfo.Extension) > -1 and PrivateFiles.IndexOf(FileName.SubString(FileName.LastIndexOf("\"))+1) = -1
'this file and extension is allowed in our search
Files.Add(FileName)
end if
next
dim FolderName as string
for each FolderName in System.IO.Directory.GetDirectories(RootFolder)
dim FldrInfo as new System.IO.DirectoryInfo(FolderName)
If PrivateFolder.IndexOf(FldrInfo.Name) = -1
'folder is allowed - do recursive search
GetAllFiles(FolderName)
end if
next
end sub
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
|