Home All Groups Group Topic Archive Search About

Resursive Folders - Exclude Folders

Author
12 Oct 2006 8:22 PM
Gabe Matteson
How would I go about excluding a list of specific directories in a listbox
from being queried using the following code? Any ideas? Thank you.

Private Sub rAllStats(ByVal sDir As String)

Try

Dim objFolder As New System.IO.DirectoryInfo(sDir)

Dim objFile As System.IO.FileInfo() = objFolder.GetFiles

Dim sFile As System.IO.FileInfo



For Each objFolder In objFolder.GetDirectories

intTDirCount += 1

rAllStats(objFolder.FullName)

Next

'process files

For Each sFile In objFile

intTFileCount += 1

Next

end try

Author
12 Oct 2006 10:04 PM
Steve Long
Hmmm, one thing you could do, if you know before hand what folders you want
to exclude, is to include the list of folders that you don't want to be
queried in your app.config file. The values could be comma seperated and
then just get the values with:
Dim arr() as string =
Configuration.ConfigurationSettings.AppSettings.Get("keyname").Split(",")
Stuff these values into a dictionary and then if the folder doesn't exist in
the dictionary, go ahead and query it.

Someone else may have a better idea but this would work. I use this
methodology for other types of things so there's no reason it wouldn't work.

Steve

Show quoteHide quote
"Gabe Matteson" <gmattesonATinqueryDOTbiz> wrote in message
news:Onc4vtj7GHA.4996@TK2MSFTNGP04.phx.gbl...
> How would I go about excluding a list of specific directories in a listbox
> from being queried using the following code? Any ideas? Thank you.
>
> Private Sub rAllStats(ByVal sDir As String)
>
> Try
>
> Dim objFolder As New System.IO.DirectoryInfo(sDir)
>
> Dim objFile As System.IO.FileInfo() = objFolder.GetFiles
>
> Dim sFile As System.IO.FileInfo
>
>
>
> For Each objFolder In objFolder.GetDirectories
>
> intTDirCount += 1
>
> rAllStats(objFolder.FullName)
>
> Next
>
> 'process files
>
> For Each sFile In objFile
>
> intTFileCount += 1
>
> Next
>
> end try
>
>
Author
13 Oct 2006 2:16 PM
Andrew Morton
Steve Long wrote:
> Hmmm, one thing you could do, if you know before hand what folders
> you want to exclude, is to include the list of folders that you don't
> want to be queried in your app.config file. The values could be comma
> seperated

I think it would be better to separate the values with a character that
can't appear in a folder name ;-)

Andrew
Author
13 Oct 2006 5:31 PM
Steve Long
You are right Andrew. I actually didn't know you could throw a comma into a
folder name. But alas, you can, as weird as that would be but you never
know...
Steve

Show quoteHide quote
"Andrew Morton" <a**@in-press.co.uk.invalid> wrote in message
news:ui3xKJt7GHA.4288@TK2MSFTNGP02.phx.gbl...
> Steve Long wrote:
>> Hmmm, one thing you could do, if you know before hand what folders
>> you want to exclude, is to include the list of folders that you don't
>> want to be queried in your app.config file. The values could be comma
>> seperated
>
> I think it would be better to separate the values with a character that
> can't appear in a folder name ;-)
>
> Andrew
>