Creates a new instance of the StreamWriter class for the specified file on the specified path, using the specified encoding and default buffer size. Overwrites or appends to an existing file, or creates a new file.
[Visual Basic] Overloads Public Sub New( _ ByVal path As String, _ ByVal append As Boolean, _ ByVal encoding As Encoding _ ) [C#] public StreamWriter( string path, bool append, Encoding encoding ); [C++] public: StreamWriter( String* path, bool append, Encoding* encoding ); [JScript] public function StreamWriter( path : String, append : Boolean, encoding : Encoding );
Exception Type | Condition |
---|---|
AccessException | Access is denied. |
ArgumentException | path is empty. |
ArgumentNullException | path is null. |
DirectoryNotFoundException | The directory to write to is not found. |
IOException | path includes an incorrect or invalid syntax for file name, directory name, or volume label syntax. |
SecurityException | The caller does not have the required permission. |
StreamWriter Class | StreamWriter Members | System.IO Namespace | StreamWriter Constructor Overload List