Createtextfile Method
Create a specified file and returnTextstreamObject, which can be used to read or write files created.
Object.Createtextfile(Filename [, overwrite [, Unicode])
Parameters
Object
Required. The name of the FileSystemObject or folder object.
Filename
Required. String expression, indicating the file to be created.
Overwrite
Optional. Boolean indicates whether existing files can be overwritten. If the file can be overwritten, the value isTrueIf the file cannot be overwritten, the value isFalse. If this value is omitted, the existing file cannot be overwritten.
Unicode
Optional. Boolean indicates whether to create a file in Unicode or ASCII format. If you create a file in unicode format, the value isTrueIf a file is created in ASCII format, the value isFalse. If this part is omitted, an ASCII file is created.
Description
BelowCodeExamplesCreatetextfileMethod To create and open a text file:
Sub createafile dim FSO, myfile set FSO = Createobject ("scripting. FileSystemObject") set myfile = FSO.Createtextfile ("C: \ testfile.txt",True)Myfile. writeline ("
This is a test.")
Myfile. Close
End sub
ForFilenameAn existing file. IfOverwriteThe parameter isFalse, Or if this parameter is not provided, an error occurs.