Creates a new instance of the StreamWriter class for the specified file on the specified path, using the default 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 _ ) [C#] public StreamWriter( string path, bool append ); [C++] public: StreamWriter( String* path, bool append ); [JScript] public function StreamWriter( path : String, append : Boolean );
Exception Type | Condition |
---|---|
AccessException | Access is denied. |
ArgumentException | path is empty. |
ArgumentNullException | path is a null reference (in Visual Basic Nothing). |
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