Open a Text File


Example One:  Creating a text file through ASP

Creates a text file in a specific directory.
In the 4th line of code just specify how the file gets opened up.  Every time the ASP page gets opened up it will create a new file and overwrite any existing data!

<%
 Const ForReading = 1, ForWriting = 2, ForAppending = 8
 Dim fso, f
 Set fso = CreateObject("Scripting.FileSystemObject")
 Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
 f.Write "Hello world!"
 
%>

Example Two: Appending to a text file through ASP

Appends to a text file in a specific directory.
In the 4th line of code just specify how the file gets opened up.  Every time the ASP page gets opened up it will create a new file and append new data to the existing file!

<%
 Const ForReading = 1, ForWriting = 2, ForAppending = 8
 Dim fso, f
 Set fso = CreateObject("Scripting.FileSystemObject")
 Set f = fso.OpenTextFile("c:\testfile.txt", ForAppending, True)
 f.Write "Hello world!"
 
%>


asp fso OpenTextFile FileSystemObject


Back To Top
© 1998 - 2017 psacake.com | My3C's

Version 7.2 | Advertise on this site