ASP FSO: Create a file CreateTextFile instance tutorial
The CreateTextFile method creates a new text file in the current folder and returns the TextStream object, which can be used to read or write to the file.
Grammar
Filesystemobject.createtextfile (Filename[,overwrite[,unicode]])
Folderobject.createtextfile (Filename[,overwrite[,unicode]])
Parameter |
Description |
FileName |
Required. The name of the file to create |
Overwrite |
Optional A Boolean value that indicates whether existing files can be overwritten. The real indication that the file can be overwritten and falsely indicates that the file cannot be overwritten. The preset value is True
|
Unicode |
Optional A Boolean value that indicates whether the file was created as a Unicode or ASCII file. It really points out that the file is created with a Unicode file, falsely indicating that it is creating an ASCII file. The default value is False
|
tutorial on file operations.
The <% Dim fs,tfile Set Fs=server.createobject ("Scripting.FileSystemObject") set TFILE=FS. CreateTextFile ("C:somefile.txt") tfile.
WriteLine ("Hello world!") tfile.close set tfile=nothing set fs=nothing%>
Tutorial on folder operations.
The <% Dim fs,fo,tfile Set Fs=server.createobject ("Scripting.FileSystemObject") set FO=FS. GetFolder ("C:test") Set Tfile=fo. CreateTextFile ("Test.txt", false) Tfile. WriteLine ("Hello world!") tfile. Close Set tfile=nothing set fo=nothing set fs=nothing%>