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
32 active users
2118 visitors today
1888 pages today
(only part of today)
Tools I use

CoverYourASP
Copyright © 1999-2016 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


I share my content

Supporting ASPRSS

Do you need a quick and easy way to link to my articles? All the information you need is published with ASPRSS...


Qualify for Free Trade Magazines

Free subscriptions to industry leading publications for those who qualify!