Creates a new instance of the StreamWriter class for the specified file on the specified path, using the specified encoding and 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, _ ByVal bufferSize As Integer _ ) [C#] public StreamWriter( string path, bool append, Encoding encoding, int bufferSize ); [C++] public: StreamWriter( String* path, bool append, Encoding* encoding, int bufferSize ); [JScript] public function StreamWriter( path : String, append : Boolean, encoding : Encoding, bufferSize : int );
Exception Type | Condition |
---|---|
ArgumentException | path is an empty string (""). |
ArgumentNullException | path or encoding is null. |
ArgumentOutOfRangeException | bufferSize is negative. |
FileNotFoundException | The file cannot be 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