Definition and usage
The CreateTextFile method creates a new text file in the current folder and returns a TextStream object for reading and writing to this file.
Grammar:
Filesystemobject.createtextfile (Filename[,overwrite[,unicode]]) folderobject.createtextfile (filename[,overwrite [, Unicode]])
filename is required. The name of the file that needs to be created.
overwrite is optional. A Boolean value that indicates whether the existing file can be overwritten. True indicates that the file can be overwritten, and False indicates that the file cannot be overwritten. The default is True.
Unicode is optional. Indicates whether the file is created in Unicode or ASCII format. True indicates that the file is created in Unicode format, False indicates that the file is created in ASCII format. The default is False.
Instance
Examples of File objects
<%dim fs,tfileset fs=server.createobject ("Scripting.FileSystemObject") set TFILE=FS. CreateTextFile ("D:\somefile.txt") tfile. WriteLine ("Hello world!") Tfile.closeset Tfile=nothingset fs=nothing%>
Example for a Folder object
<%dim fs,fo,tfileset fs=server.createobject ("Scripting.FileSystemObject") Set Fo=fs. GetFolder ("D:\test") Set Tfile=fo. CreateTextFile ("Somefile.txt", false) Tfile. WriteLine ("Hello world!") Tfile. CloseSet Tfile=nothingset Fo=nothingset fs=nothing%>
"Recommended"
1. asp FSO: Create a file CreateTextFile instance tutorial
2. CreateTextFile examples in FSO components