StreamWriter Constructor (String^, Boolean, Encoding^)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Initializes a new instance of the StreamWriter class for the specified file by using the specified encoding and default 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.

The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must not exceed 248 characters, and file names must not exceed 260 characters.

This constructor initializes the Encoding property using the encoding parameter. For additional information, see Encoding.

path can be a file name, including a file on a Universal Naming Convention (UNC) share.

path is not required to be a file stored on disk; it can be any part of a system that supports access via streams.

Caution

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.