Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

StreamWriter Constructor

.NET Micro Framework 3.0
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)

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.

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.

Hh399670.caution(en-us,MSDN.10).gifCaution
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.

Available in the .NET Micro Framework versions 3.0, 4.0, 4.1, and 4.2.

Community Additions

ADD
Show:
© 2015 Microsoft