VBScript » Folder » CreateTextFile

Version: 3.0

Syntax:
object.CreateTextFile filename [, overwrite[, unicode]]
overwrite
The optional overwrite parameter returns a Boolean value - True (the default) permits overwriting of existing files while False does not.
unicode
The other optional parameter, unicode, is also a Boolean. In this case, True creates a Unicode file and False (the default) creates an AscII file.

This method is used to create a text file and returns a TextStreamObject that can then be used to write to and read from the file.

Examples

Code:
<%
dim filesys, demofolder, filetxt
Set filesys = CreateObject("Scripting.FileSystemObject")
Set demofolder = filesys.GetFolder("c:\projects\")
Set filetxt = demofolder.CreateTextFile("somefile.txt", True)
filetxt.WriteLine("Your text goes here.")
filetxt.Close
%>
Explanation:

This example creates a text file called, somefile.txt, with the following path: c:\projects\demofolder\somefile.txt