Mono Class Library: System.Xml.XmlTextWriter Overview | Members

System.Xml.XmlTextWriter Constructor

Constructs and initializes a new instance of the System.Xml.XmlTextWriter class using the specified file.

public XmlTextWriter (string filename, System.Text.Encoding encoding)

Parameters

filename
A string specifying the path and name of the file to write to.
encoding
The System.Text.Encoding to generate, or null.
encoding
Documentation for this section has not yet been entered.

Permissions

TypeReason
System.Security.Permissions.FileIOPermissionRequires permission to write to files. See System.Security.Permissions.FileIOPermissionAccess.Write.

Exceptions

TypeReason
ArgumentException

filename is string.Empty, contains only white space, or contains one or more implementation-specific invalid characters.

-or-

The encoding is not supported.

ArgumentNullExceptionfilename is null.
System.IO.DirectoryNotFoundExceptionThe directory path specified in filename does not exist.
System.IO.IOExceptionfilename includes an invalid syntax for the path or file name.
System.IO.PathTooLongExceptionThe specified path, file name, or both exceeds the system-defined maximum length.
System.Security.SecurityExceptionThe caller does not have the required permissions.
UnauthorizedAccessExceptionWrite access is not permitted by the operating system for the path specified in filename.

Remarks

If filename exists, it is truncated and overwritten with the new content.

If encoding is null, the file is written as UTF-8 and the encoding attribute is omitted from the processing instruction.

The following properties are initialized to the specified values:

XmlTextWriter.Formatting to Formatting.None.

XmlTextWriter.Indentation to 2.

XmlTextWriter.IndentChar to the space character.

XmlTextWriter.Namespaces to true.

XmlTextWriter.QuoteChar to the double quote character.

XmlTextWriter.WriteState to WriteState.Start.

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0