Vbs Tutorial: method-createtextfile Method

Source: Internet
Author: User

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. CloseEnd sub

ForFilenameAn existing file. IfOverwriteThe parameter isFalse, Or if this parameter is not provided, an error occurs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.