FileSystemObject.CreateTextFile Method (VB6)

Named Arguments

Yes

Syntax

oFileSysObj.CreateTextFile Filename [, Overwrite[, _
          Unicode]])


oFileSysObj

Use: Required

Data Type: FileSystemObject object

Any object variable returning a FileSystemObject object.


Filename

Use: Required

Data Type: String

Any valid filename, along with an optional path.


Overwrite

Use: Optional

Data Type: Boolean

Flag indicating if an existing file of the same name should be overwritten.


Unicode

Use: Optional

Data Type: Boolean

Flag indicating if newfilename is to be written in Unicode or ASCII.

Return Value

A TextStream object.

Description

Creates a new file and returns its TextStream object.

Rules at a Glance

  • Wildcard characters aren't allowed in Filename.

  • Filename can be a relative or absolute path.

  • If no path is specified in Filename, the application's current drive and directory are used.

  • If the path specified in Filename doesn't exist, the method fails.

  • The default value for Overwrite is False.

  • If Unicode is set to True, the file is created in Unicode; otherwise it's created as an ASCII text file. The default value for Unicode is False.

Programming Tips and Gotchas

  • The newly created text file is automatically opened only for writing. If you subsequently wish to read from the file, you must first close it and reopen it in read mode.

  • If the path referred to in Filename is set to read-only, the CreateTextFile method fails regardless of the value of Overwrite.

  • If the user has adequate rights, Filename can contain a network path or share name. For example:

    CreateTextFile "\NTSERV1RootTestmyFile.doc"

  • You must use the Set statement to assign the TextStream object to your local object variable.

See Also

Folder.CreateTextFile Method
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset