StreamWriter Class
Implements a class for writing data to a file.
Example
The following creates a text file and writes two consecutive lines of data to the file (see StreamReader for the read example):
using elsystem.io;
var: StreamWriter myFile(null);
myFile = StreamWriter.Create("c:\ExistingFolder\myTestFile.txt");
myFile.WriteLine("This text will be written to line 1 of the file.");
myFile.WriteLine("And a date " + elsystem.DateTime.Now.tostring() + " is written to the second line");
myFile.Close();
Namespace: elsystem.io
Properties
Name | Type | Description | |
AutoFlush | bool | Gets or sets a value indicating whether the StreamWriter will flush its buffer to the underlying file after every call to write to the stream. | |
Encoding | object | Gets the character Encoding for the current instance. |
Methods
This class uses overload methods.
Name | Description | |
Close() | Closes the StreamWriter object and the underlying file, and releases any system resources associated with the StreamWriter. | |
Create(path) | Initializes a new instance specifying the full path
of the file to write. |
|
Create(path,append) | Initializes a new instance specifying the full path of the file to write. Setting append to True allows writing to an existing file. | |
Create(path,append,enc) | Initializes a new instance specifying the full path of the file to write. Setting append to True allows writing to an existing file. The enc parameter specifies the character Encoding. | |
Flush | Clears all buffers and causes any buffered data to be written to the underlying file. | |
Write(bool) | Writes the text representation of a boolean value to the file. | |
Write(string) | Writes a string to the file. | |
Write(double) | Writes the text representation of a 4-byte floating-point value to the file. | |
Write(float) | Writes the text representation of an 8-byte floating-point value to the file. | |
Write(int) | Writes the text representation of a 4-byte signed integer to the file. | |
Write(int64) | Writes the text representation of an 8-byte signed integer to the file. | |
Write(elsystem.Object) | Writes the text representation of an object to the file by calling ToString on that object. | |
Write(string, int, int) | Writes a selected string to the file where string is the initial string; int is the starting position of the selected string (zero based) and int is the length of the selection. | |
Write(string, params elsystem.Object) | Writes a string to the file where string is the initial string and params elsystem.Object is a series of objects. The initial string contains object references within {} brackets which are replaced by the referenced object (zero based). | |
WriteLine | Writes a line terminator to the text file. | |
WriteLine(bool) | Writes the text representation of a Boolean followed by a line terminator to the text file. | |
WriteLine(string) | Writes a string followed by a line terminator to the text stream. | |
WriteLine(double) | Writes the text representation of a 8-byte floating-point value followed by a line terminator to the text file. | |
WriteLine(float) | Writes the text representation of a float value followed by a line terminator to the text file. | |
WriteLine(int) | Writes the text representation of a 4-byte signed integer followed by a line terminator to the text file. | |
WriteLine(int64) | Writes the text representation of an 8-byte signed integer followed by a line terminator to the text file. | |
WriteLine(elsystem.Object) | Writes the text representation of an object by calling ToString on this object, followed by a line terminator to the text file. | |
WriteLine(string, int, int) | Writes a selected string to the file followed by a line terminator where string is the initial string; int is the starting position of the selected string (zero based) and int is the length of the selection. | |
WriteLine(string, params elsystem.Object) | Writes a string to the file followed by a line terminator where string is the initial string and params elsystem.Object is a series of objects. The initial string contains object references within {} brackets which are replaced by the referenced object (zero based). See Composite Formatting for more information. |
Inheritance Hierarchy
elsystem.io.StreamWriter