Codecore Logo
Quick Search
»
Advanced Search »

TextFileWriter Object

RSS
Facilitates writing to a standard text file.

Accessing files and directories is done under the context of the user that the application or service is running under. This can cause some file permissions/access rights issues if the file does not allow access to that user.


Constructors

none

Instance Properties

none

Static Methods

WriteAllText

Creates a new file, writes the specified string to the file. If the target file already exists, it is overwritten.

Syntax:

void WriteAllText(String path, String )

Parameters:

path: The file to append the specified string to.
contents: The string to append to the file.

Example:


s = "Joe\r\nMike\r\nSandy\r\n";
TextFileWriter.WriteAllText("c:\myfiles\names.txt", s);

AppendAllText

Appends the specified string to the file, creating the file if it does not already exist

Syntax:

void AppendAllText(String path, String contents)

Parameters:

path: The file to append the specified string to.
contents: The string to append to the file.

Example:


s = "Tammy";
TextFileWriter.AppendAllText("c:\myfiles\names.txt", s);

CreateText

Creates or opens a file for writing UTF-8 encoded text.

Syntax:

TextFileWriter CreateText(String path)

Parameters:

path: The file to be opened for writing.

Return Value

A TextFileWriter for writing.

Example:


file = TextFileWriter.CreateText("c:\myfiles\names.txt");

Instance Methods

Write( String )

Writes the string to the file.

Syntax:

void Write(String value)

Parameters

value: The value to write to the file.

Example:


file = TextFileWriter.CreateText("c:\myfiles\names.txt");
file.Write("Joe\r\nMike\r\nSandy\r\n");
file.Close();

Write( Number )

Writes the number to the file.

Syntax:

void Write(Number value)

Parameters

value: The value to write to the file.

Example:


file = TextFileWriter.CreateText("c:\myfiles\myfile.txt");
n = 12;
file.Write(n);
file.Close();

Write( Boolean )

Writes the text representation of a boolean to the file.

Syntax:

void Write(Boolean value)

Parameters

value: The value to write to the file.

Example:


file = TextFileWriter.CreateText("c:\myfiles\myfile.txt");
b = false;
file.Write( b );
file.Close();

WriteLine( String )

Writes the text representation of a boolean followed by a line terminator to the file.

Syntax:

void WriteLine(String value)

Parameters

value: The value to write to the file.

Example:


file = TextFileWriter.CreateText("c:\myfiles\names.txt");
file.WriteLine("Joe");
file.WriteLine("Mike");
file.WriteLine("Sandy");
file.Close();

WriteLine( Number )

Writes a number followed by a line terminator to the file.

Syntax:

void WriteLine(Number value)

Parameters

value: The value to write to the file.

Example:


file = TextFileWriter.CreateText("c:\myfiles\myfile.txt");
n = 12;
file.WriteLine(n);
file.Close();

WriteLine( Boolean )

Writes the text representation of a boolean followed by a line terminator to the file.

Syntax:

void WriteLine(Boolean value)

Parameters

value: The value to write to the file.

Example:


file = TextFileWriter.CreateText("c:\myfiles\myfile.txt");
b = false;
file.WriteLine( b );
file.Close();

Close

Closes the current file.

Syntax:

void Close( )

Example:


file = TextFileWriter.OpenText("c:\myfiles\names.txt");
s = file.Peek();
file.Close();

See Also

TextFileReader Object
File System Object
Scripting
Privacy Policy | Conditions Of Use

Copyright ©2014 Codecore Technologies, All rights reserved.