ASP CreateTextFile Method
Definition and Usage
The CreateTextFile method can create a new text file in the current folder and return a TextStream object that can be used to read or write to the file.
Syntax:
FileSystemObject.CreateTextFile(filename[,overwrite[,unicode]]) FolderObject.CreateTextFile(filename[,overwrite[,unicode]])
Parameters | Description |
---|---|
filename | Required. The name of the file to be created. |
overwrite | Optional. A boolean value indicating whether it is possible to overwrite an existing file. True indicates that it is possible to overwrite the file, while False indicates that it is not possible to overwrite the file. The default is True. |
unicode | Optional. A boolean value indicating whether the file is created as a Unicode or ASCII file. True indicates that the file is created as a Unicode file, while False indicates that the file is created as an ASCII file. The default is False. |
Instance for FileSystemObject
<% 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 %>
Instance for Folder object
<% 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 %>