When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
ASPFAQs.com
Message Board
Related Web Technologies
User Tips!
Coding Tips

Sections:
Sample Chapters
Commonly Asked Message Board Questions
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Security
Stump the SQL Guru!
XML Info
Information:
Feedback
Author an Article
ASP ASP.NET ASP FAQs Message Board Feedback
Print this page.
Published: Wednesday, February 02, 2000

Generating a Web Site File System Report, Part 3


  • Read Part 1
  • Read Part 2


  • In Part 2 we examined the TraverseFolder of ExamineWeb.asp in great detail. In this part, we are going to focus on the remainder of the code. As always, let's dive on into the code!

    - continued -

      Dim dtStartReport, dtStopReport
      dtStartReport = Now()
    
      'Create dictionary instances
      Dim objDict
      Set objDict = Server.CreateObject("Scripting.Dictionary")
    
      Dim objSizeDict
      Set objSizeDict = Server.CreateObject("Scripting.Dictionary")
    
    
      Dim objFSO
      Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    
      'Determine if we need to recurse through the directories
      Dim bolRecurseDirectories
      bolRecurseDirectories = Request("chkRecurse")
      If bolRecurseDirectories = "on" then
        bolRecurseDirectories = True
      Else
        bolRecurseDirectories = False
      End If
    
    
      'Get the physical path of the root folder
      Dim strRootFolder
      strRootFolder = Server.MapPath("/")
    
      'Obtain an folder object instance of the default root directory
      Dim objFolder
      Set objFolder = objFSO.GetFolder(strRootFolder)
    
      'Clean up objFSO
      Set objFSO = Nothing
    
      'Traverse through objFoldre, populating our two dictionaries
      TraverseFolder objFolder, objDict, objSizeDict, bolRecurseDirectories
    
      'Clean up objFolder
      Set objFolder = Nothing
    
      'Mark the report's stopping time...
      dtStopReport = Now()
    %>
    

    We begin by declaring two variables, dtStartReport and dtStopReport. These two variables will be used to determine the starting and stopping time of the report. Since the report may take several seconds to run on large sites, noting the starting and stopping times serve as useful metrics.

    Next we create two instances of the Dictionary objects, objDict and objSizeDict, which will contain the number of files that fall under a particular file extension, and that group's associated file size, respectively. We then create an instance of the FileSystemObject, which we'll use to grab a folder object instance of the Web's root directory.

    This is followed by determining whether or not the user wants to recurse the directories. We check to see if a particular value is in the QueryString. If chkRecurse equals on, then the user is interested in recursing the directories; else, the user doesn't want to recurse. Next we obtain the physical path of the root Web directory using Server.MapPath. If you are unfamiliar with Server.MapPath, be sure to read Using Server.MapPath. Once we have the physical path of the root Web directory, we can use the GetFolder method of the FileSystemObject to store the folder information in objFolder.

    Finally we are ready to call TraverseFolder, passing in the root Web directory (objFolder), the two empty dictionary objects (objDict and objSizeDict), and a boolean value representing if we are interested in having the directories recursed or not (bolRecurseDirectories).

    We end this section of code by setting dtStopReport to the current time. We're not quite completed with ExamineWeb.asp. We still need to display the results of the report, generate the two bar graphs, and provide drill down links to the DetailedReport.asp report! Quite a bit more, eh? We'll finish off ExamineWeb.asp in Part 4.

  • Read Part 4
  • Read Part 2
  • Read Part 1


  • ASP.NET [1.x] [2.0] | ASPMessageboard.com | ASPFAQs.com | Advertise | Feedback | Author an Article