"FileSystemObject" Class - File System

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

FileSystemObject: A class represents the file system of the operating system where the Web server is running. Major methods and properties include:

Below is a simple ASP page to how to create a folder and copy a file by using the FileSystemObject class.

<script language="vbscript" runat="server">
'  file_sytem.asp
'  Copyright (c) 1999 by Dr. Herong Yang
'  This program shows how to use the FileSystemObject class.
'
   response.write("<html><body>")
   response.write("<b>Tests on the FileSystemObject class</b>:<br/>")
   ' Getting the FileSystemObject object
   set fs = CreateObject("Scripting.FileSystemObject")
   if fs.FolderExists("c:\temp\backup") then 
      fs.DeleteFolder("c:\temp\backup")
   end if
   set d = fs.CreateFolder("c:\temp\backup")
   fs.CopyFile "c:\inetpub\wwwroot\file_system.asp", _
      "c:\temp\backup\file_system.asp"
   response.write("File copied: c:\temp\backup\file_system.asp<br/>")
   response.write("</body></html>")
</script>

Output:

Tests on the FileSystemObject class:
File copied: c:\temp\backup\file_system.asp

It's interesting to note that:

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

 Full Version in PDF/EPUB