Open In App

ASP OpenTextFile Method

The ASP OpenTextFile Method is used to open a specified file. It returns a TextStream object that can be used to read, write and append contents to the File. It is an in-built function of the FileSystem Object. 

Syntax:



FileSystemObject.OpenTextFile(fname,mode,create,format) 

Parameter Value:

Example Code:  Below code illustrates that how to open a new file for writing the content






<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile(Server.MapPath("GFG.txt"),2,true)
response.write("File is open for purpose of writing")
f.WriteLine("This text will be added to the end of file")
f.Close
set f=Nothing
set fs=Nothing
%>

 

 

Output:

 

File is open for purpose of writing

 

Article Tags :