XmlTextWriter 建構函式

定義

建立 XmlTextWriter 類別的執行個體。

多載

XmlTextWriter(TextWriter)

使用指定的 TextWriter 來建立 XmlTextWriter 類別的執行個體。

XmlTextWriter(Stream, Encoding)

使用指定的資料流和編碼方式,建立 XmlTextWriter 類別的執行個體。

XmlTextWriter(String, Encoding)

使用指定的檔案建立 XmlTextWriter 類別的執行個體。

備註

注意

從 .NET Framework 2.0 開始,建議您使用 XmlWriter.Create 方法和 XmlWriterSettings 類別來建立 XmlWriter 實例,以利用新功能。

XmlTextWriter(TextWriter)

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

使用指定的 TextWriter 來建立 XmlTextWriter 類別的執行個體。

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)

參數

w
TextWriter

要寫入的目標 TextWriter。 它假設已將 TextWriter 設定為正確的編碼方式。

備註

注意

從 .NET Framework 2.0 開始,建議您使用 XmlWriter.Create 方法和 XmlWriterSettings 類別來建立 XmlWriter 實例,以利用新功能。

適用於

XmlTextWriter(Stream, Encoding)

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

使用指定的資料流和編碼方式,建立 XmlTextWriter 類別的執行個體。

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)

參數

w
Stream

要寫入其中的資料流。

encoding
Encoding

要產生的編碼方式。 如果編碼方式為 null,它會以 UTF-8 格式寫出資料流,並忽略來自 ProcessingInstruction 的編碼方式屬性。

例外狀況

不支援該編碼方式,或無法寫入至資料流。

wnull

備註

注意

從 .NET Framework 2.0 開始,建議您使用 XmlWriter.Create 方法和 XmlWriterSettings 類別來建立 XmlWriter 實例,以利用新功能。

適用於

XmlTextWriter(String, Encoding)

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

使用指定的檔案建立 XmlTextWriter 類別的執行個體。

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)

參數

filename
String

要寫入至的檔名。 如果這個檔案存在,就會將它截斷並以新內容將其覆寫。

encoding
Encoding

要產生的編碼方式。 如果編碼方式為 null,它會以 UTF-8 格式寫出檔案,並忽略來自 ProcessingInstruction 的編碼方式屬性。

例外狀況

編碼方式不受支援、檔案名稱是空的、只含有泛空白字元 (White Space),或含有一個或多個無效字元。

存取遭到拒絕。

檔案名稱為 null

找不到要寫入的目錄。

檔案名稱包含關於檔案名稱、目錄名稱或磁碟標籤語法的不正確或無效語法。

呼叫端沒有必要的權限。

備註

注意

從 .NET Framework 2.0 開始,建議您使用 XmlWriter.Create 方法和 XmlWriterSettings 類別來建立 XmlWriter 實例,以利用新功能。

適用於