XmlTextWriter 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立 XmlTextWriter 類別的執行個體。
多載
| 名稱 | Description |
|---|---|
| XmlTextWriter(TextWriter) |
使用指定的 |
| XmlTextWriter(Stream, Encoding) |
使用指定的串流和編碼建立該 |
| XmlTextWriter(String, Encoding) |
使用指定的檔案建立類別 XmlTextWriter 的實例。 |
備註
Note
建議您使用 XmlWriter 方法和 XmlWriter.Create 類別來建立XmlWriterSettings實例,以利用新功能。
XmlTextWriter(TextWriter)
使用指定的 XmlTextWriter建立該類別的實例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)
參數
寫信的對象 TextWriter 。 假設 已經 TextWriter 設定為正確的編碼。
備註
Note
建議您使用 XmlWriter 方法和 XmlWriter.Create 類別來建立XmlWriterSettings實例,以利用新功能。
適用於
XmlTextWriter(Stream, Encoding)
使用指定的串流和編碼建立該 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
例外狀況
不支援編碼,或無法寫入串流。
w 是 null。
備註
Note
建議您使用 XmlWriter 方法和 XmlWriter.Create 類別來建立XmlWriterSettings實例,以利用新功能。
適用於
XmlTextWriter(String, Encoding)
使用指定的檔案建立類別 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略 。
例外狀況
不支援編碼;檔名為空、僅有空白,或包含一個或多個無效字元。
存取遭到拒絕。
檔名為 null。
找不到要寫入的目錄。
檔名包含錯誤或無效的檔案名稱、目錄名稱或卷軸標籤語法。
來電者沒有所需的權限。
備註
Note
建議您使用 XmlWriter 方法和 XmlWriter.Create 類別來建立XmlWriterSettings實例,以利用新功能。