Redigeeri

Jagamisviis:


XmlTextWriter Constructors

Definition

Creates an instance of the XmlTextWriter class.

Overloads

XmlTextWriter(TextWriter)

Creates an instance of the XmlTextWriter class using the specified TextWriter.

XmlTextWriter(Stream, Encoding)

Creates an instance of the XmlTextWriter class using the specified stream and encoding.

XmlTextWriter(String, Encoding)

Creates an instance of the XmlTextWriter class using the specified file.

Remarks

Note

Starting with the .NET Framework 2.0, we recommend that you create XmlWriter instances by using the XmlWriter.Create method and the XmlWriterSettings class to take advantage of new functionality.

XmlTextWriter(TextWriter)

Source:
XmlTextWriter.cs
Source:
XmlTextWriter.cs
Source:
XmlTextWriter.cs

Creates an instance of the XmlTextWriter class using the specified TextWriter.

public:
 XmlTextWriter(System::IO::TextWriter ^ w);
public XmlTextWriter (System.IO.TextWriter w);
new System.Xml.XmlTextWriter : System.IO.TextWriter -> System.Xml.XmlTextWriter
Public Sub New (w As TextWriter)

Parameters

w
TextWriter

The TextWriter to write to. It is assumed that the TextWriter is already set to the correct encoding.

Remarks

Note

Starting with the .NET Framework 2.0, we recommend that you create XmlWriter instances by using the XmlWriter.Create method and the XmlWriterSettings class to take advantage of new functionality.

Applies to

XmlTextWriter(Stream, Encoding)

Source:
XmlTextWriter.cs
Source:
XmlTextWriter.cs
Source:
XmlTextWriter.cs

Creates an instance of the XmlTextWriter class using the specified stream and encoding.

public:
 XmlTextWriter(System::IO::Stream ^ w, System::Text::Encoding ^ encoding);
public XmlTextWriter (System.IO.Stream w, System.Text.Encoding? encoding);
public XmlTextWriter (System.IO.Stream w, System.Text.Encoding encoding);
new System.Xml.XmlTextWriter : System.IO.Stream * System.Text.Encoding -> System.Xml.XmlTextWriter
Public Sub New (w As Stream, encoding As Encoding)

Parameters

w
Stream

The stream to which you want to write.

encoding
Encoding

The encoding to generate. If encoding is null it writes out the stream as UTF-8 and omits the encoding attribute from the ProcessingInstruction.

Exceptions

The encoding is not supported or the stream cannot be written to.

Remarks

Note

Starting with the .NET Framework 2.0, we recommend that you create XmlWriter instances by using the XmlWriter.Create method and the XmlWriterSettings class to take advantage of new functionality.

Applies to

XmlTextWriter(String, Encoding)

Source:
XmlTextWriter.cs
Source:
XmlTextWriter.cs
Source:
XmlTextWriter.cs

Creates an instance of the XmlTextWriter class using the specified file.

public:
 XmlTextWriter(System::String ^ filename, System::Text::Encoding ^ encoding);
public XmlTextWriter (string filename, System.Text.Encoding? encoding);
public XmlTextWriter (string filename, System.Text.Encoding encoding);
new System.Xml.XmlTextWriter : string * System.Text.Encoding -> System.Xml.XmlTextWriter
Public Sub New (filename As String, encoding As Encoding)

Parameters

filename
String

The filename to write to. If the file exists, it truncates it and overwrites it with the new content.

encoding
Encoding

The encoding to generate. If encoding is null it writes the file out as UTF-8, and omits the encoding attribute from the ProcessingInstruction.

Exceptions

The encoding is not supported; the filename is empty, contains only white space, or contains one or more invalid characters.

Access is denied.

The filename is null.

The directory to write to is not found.

The filename includes an incorrect or invalid syntax for file name, directory name, or volume label syntax.

The caller does not have the required permission.

Remarks

Note

Starting with the .NET Framework 2.0, we recommend that you create XmlWriter instances by using the XmlWriter.Create method and the XmlWriterSettings class to take advantage of new functionality.

Applies to