StreamWriter Constructor
Initializes a new instance of the StreamWriter class for the specified file on the specified path, using the default encoding and buffer size. If the file exists, it can be either overwritten or appended to. If the file does not exist, this constructor creates a new file.
Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Syntax
public StreamWriter (
string path,
bool append
)
Parameters
- path
The complete file path to write to. - append
Determines whether data is to be appended to the file. If the file exists and append is false, the file is overwritten. If the file exists and append is true, the data is appended to the file. Otherwise, a new file is created.
Remarks
This constructor creates a StreamWriter with UTF-8 encoding without a Byte-Order Mark (BOM), so its GetPreamble method returns an empty byte array. For additional information, see Encoding.
The path parameter can be a file name, including a file on a Universal Naming Convention (UNC) share.
The path parameter is not required to be a file stored on disk; it can be any part of a system that supports access using streams.
Warning
When you compile a set of characters with a particular cultural setting and retrieve those same characters with a different cultural setting, the characters might not be interpretable, and could cause an exception to be thrown.
Version Information
Available in the .NET Micro Framework versions 3.0, 4.0, 4.1, and 4.2.