"Folder" Class - File Folder

This section provides a tutorial example on how to use the Folder class that represents a file folder of a file system. Folder class is provided in the Scripting Runtime DLL, scrrun.dll.

Folder: A class representing a file folder in a file system. It offers the following properties and methods:

The following ASP shows how the Folder object can be used to list all the information about a folder:

<script language="vbscript" runat="server">
'  folder_test.asp
'  Copyright (c) 1999 by Dr. Herong Yang
'  This program shows how to browse the directory tree of a drive.
'
   response.write("<html><body>")
   response.write("<b>Tests on the folder tree</b>:<br/>")
   ' Creating a FileSystemObject object
   set fs = CreateObject("Scripting.FileSystemObject")
   ' Getting a specific folder
   set f = fs.GetFolder("c:\inetpub\wwwroot")
   call displayFolderInfo(f)
   sub displayFolderInfo(f)
      response.write("Path = " & f.Path & "<br/>")
      response.write("Name = " & f.Name & "<br/>")
      response.write("Short Name = " & f.ShortName & "<br/>")
      response.write("Short Path = " & f.ShortPath & "<br/>")
      response.write("Drive = " & f.Drive & "<br/>")
      response.write("Size = " & f.Size & "<br/>")
      response.write("Attributes = " & f.Attributes & "<br/>")
      response.write("Date created = " & f.DateCreated & "<br/>")
      response.write("Is Root Folder = " & f.IsRootFolder & "<br/>")
      set l = f.SubFolders
      for each sf in l
         response.write("Sub Folder = " & sf.Name & "<br/>")
      next
      set l = f.Files
      for each sf in l
         response.write("File = " & sf.Name & "<br/>")
      next
   end sub
   response.write("</body></html>")
</script>

Output:

Tests on the folder tree:
Path = C:\Inetpub\wwwroot
Name = wwwroot
Short Name = wwwroot
Short Path = C:\inetpub\wwwroot
Drive = c:
Size = 439424
Attributes = 48
Date created = 4/19/2000 3:16:15 PM
Is Root Folder = False
Sub Folder = asp
Sub Folder = aspnet_client
Sub Folder = images
Sub Folder = list
Sub Folder = _private
Sub Folder = _vti_cnf
Sub Folder = _vti_log
Sub Folder = _vti_pvt
Sub Folder = _vti_script
Sub Folder = _vti_txt
File = default.asp
File = default.htm
File = hello.asp
File = hello.html
File = help.gif
File = iisstart.asp
File = localstart.asp
File = mmc.gif
File = pagerror.gif
File = postinfo.html
File = print.gif
File = warning.gif
File = web.gif
File = win2000.gif
File = _vti_inf.html

Last update: 2002.

Table of Contents

 About This Book

 ASP (Active Server Pages) Introduction

 IIS (Internet Information Services) 5.0

 MS Script Debugger

 VBScript Language

 ASP Built-in Run-time Objects

 ASP Session

 Creating and Managing Cookies

 Managing Sessions with and without Cookies

scrrun.dll - Scripting Runtime DLL

 What Is scrrun.dll?

 "Dictionary" Class - Collection of Key-Value Pairs

 "FileSystemObject" Class - File System

 "Drive" Class - Disk Drive

"Folder" Class - File Folder

 "File" Class - File Folder

 "TextStream" Class - Input or Output Stream

 Managing Response Header Lines

 Calculation Speed and Response Time

 ADO (ActiveX Data Object) DLL

 Working with MS Access Database

 Guest Book Application Example

 References

 PDF Printing Version