Definition and Usage
The CreateTextFile method creates a new text file in the current folder and returns a TextStream object for reading and writing this file.
Syntax:
FileSystemObject.CreateTextFile(filename[,overwrite[,unicode]])FolderObject.CreateTextFile(filename[,overwrite[,unicode]])
filenameRequired. The name of the file that needs to be created.
overwriteOptional. A Boolean value indicating whether existing files can be overwritten. True means the file can be overwritten, False means the file cannot be overwritten. The default is True.
unicodeOptional. 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.
Example
Example for File object
<% dim fs,tfile set fs=Server.CreateObject("Scripting.FileSystemObject") set tfile=fs.CreateTextFile("d:\somefile.txt")tfile.WriteLine("Hello World!") tfile.close set tfile=nothing set fs=nothing %>
For Folder object Example
<% dim fs,fo,tfile Set fs=Server.CreateObject("Scripting.FileSystemObject") Set fo=fs.GetFolder("d:\test") Set tfile=fo.CreateTextFile("somefile.txt",false)tfile.WriteLine("Hello World!") tfile.Close set tfile=nothing set fo=nothing set fs=nothing %>
[Related recommendations]
1.asp fso: Create file CreateTextFile example tutorial
2.Detailed explanation of CreateTextFile instance in FSO component
The above is the detailed content of Share the definition and usage of ASP CreateTextFile. For more information, please follow other related articles on the PHP Chinese website!