FileSystemObject provides access to a computer's file system. Some of the common tasks that can be performed using FileSystemObject are to check for a particular folder, drive, or file, and create/modify/delete files (if you have proper folder/file permissions).
To start with, following is the code which describes how to use the FileSystemObject to create a text file, and write some text:
<%
Set fso = CreateObject ( "Scripting.FileSystemObject" )
Set a = fso.CreateTextFile( "c:\testfile.txt" , True )
a.WriteLine( "This is a test." )
a.Close
set a = nothing
set fso = nothing
%>
You create an instance of FileSystemObject , and create a text file c:\testfile.txt , and write some text into it. The second method to create a text file is by using OpenTextFile method of FileSystemObject object with ForWriting flag.
<%
Const ForWriting = 2
Set a = fsoOpenTextFile ( "c:\testfile.txt" , ForWriting , True )
%>
Following are the modes, by which files can be opened:
ForReading (Constant value - 1) - Open a file for reading only.
ForWriting (Constant value - 2) - Open a file for writing.
ForAppending (Constant value - 8) - Open a file and write to the end of the file.