This example uses the OpenTextFile method of FileSystemObject Object. Example One: Creating a text file through ASPCreates a text file in a specific directory. In the 4th line of code just specify how the file gets opened up. Everytime 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. Everytime 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!"
|