File Access

Overview

The File Access component provides access to the server's file system through the FileSystemObject object, and can be used to accomplish most typical file and directory manipulation and management.

Code Tour

This script first creates an instance of the FileSystemObject with the Server.CreateObject, using the PROGID of Scripting.FileSystemObject. The reference returned from this method can be used to accomplish virtually any file and directory manipulations and management tasks that you can think of.

This script calls Server.MapPath to determine the actual physical path that corresponds to the \iissamples virtual directory, then uses the FileSystemObject instance to open a file called mytextfile.txt in that directory. The script uses the reference to this new text file object, MyFile, to access the WriteLine and ReadAll methods, to write to and read from the file.

Location

The VBScript and JScript versions of this script are available in the IIS samples directory, at ...\asp\components\FileSystem_VBScript.asp and ...\asp\components\FileSystem_JScript.asp.