ASP/.NET Web Hosting
* 3 Months FREE *
CLICK HERE!
 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
60 active users
1748 visitors today
1624 pages today
how is this done?
ASP.NET Showcase
ASP.NET Graph and Chart Component with FREE developer version

ASP.NET Shopping Cart and E-commerce Control with FREE trial download

ASP.NET Web Hosting with free month and setup

$15 Domain Name Registration from .DNR.
As seen on these sites
Special thanks go to the sites that support me by publishing my articles.
See more

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

ASP.NET Blog
ASPRSS
ShawThing

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

Selling products online - read how James does it now


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?


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...