Wife/Girlfriend/Sister?
Pepper Spray &
Stun Gun Specials!
KEEP THEM SAFE.
 CoverYourASP --> Walking through server folders and files --> Part 2

Free membership

Join in the fun! Sign in
Member Services

Site navigation
Download the entire site!
Search my articles
Free Magazines
Browse the directory

Send me feedback
Buy my boxer shorts

Recommend this page
Printer-friendly page

Resources I recommend
Link to my site
Advertising slashed!
About your privacy
Legal stuff
Site statistics
54 active users
2020 visitors today
4260 pages today
how is this done?
Tools I use

CoverYourASP
Copyright © 1999-2010 James Shaw.
All rights reserved.

ASP.NET Blog
RSS submissions
E-commerce

Now open source with SourceForge!

Inside WalkFolders( )

Let's step through the WalkFolders function, line by line. It's a very short function, so it shouldn't take long!

// ============================================
// walk through the folder, listing all files and descending into sub-folders
// calls fFolderNotify and fFileNotify functions
// ============================================
function WalkFolders ( oFolder, nLevel, fFolderNotify, fFileNotify )
{
   var sName = oFolder.Name;

   // skip test folders (start with _)
   if ( sName.charAt ( 0 ) == '_' )
      return;

   // notify that we're in new folder
   fFolderNotify ( oFolder, nLevel );

The first thing we do is to look at the Name property of the Folder object passed in.

As a rule, I always skip anything that start with an underscore characters - that way I can always "hide" temporary test folders or files. The charAt( 0 ) method compares the first (zero-based) character to "_", and immediately exits the function if it matches.

Next, because we are about to start looking through a new folder, we call the fFolderNotify function passed in. It's just called like a normal function, so you don't even have to bother with the awkward syntax used when de-referencing a function pointer in C (believe me, you don't want to know).

The point to this is simple. Because the "client" who called this function passes in the functions to be called, they can re-use the WalkFolders( ) function for many purposes.

Part 3: Walking through the files...

Featured sponsor
My favorite resources

Tiki Statues - Tiki Masks - Tiki Totems



See my source code
wherever you see this icon...

You can also download the entire site source code for FREE!

CoverYourASP Mugs, T-shirts, caps - even Boxer shorts...
I don't make a penny from these, but they're a lot of fun! Don't you need a new mouse mat?