XpsDocument.Close 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
關閉 XPS 文件 Package。
public:
void Close();
public void Close();
member this.Close : unit -> unit
Public Sub Close ()
範例
以下範例展示了如何開啟、插入內容及關閉 XpsDocument。
// Create an XpsDocument package (without PrintTicket).
{
Package^ package = Package::Open(packageName);
try
{
XpsDocument^ xpsDocument = gcnew XpsDocument(package);
// Add the package content (false=without PrintTicket).
AddPackageContent(xpsDocument, false);
// Close the package.
xpsDocument->Close();
} finally
{
delete package;
}
// Create an XpsDocument package (without PrintTicket).
using (Package package = Package.Open(packageName))
{
XpsDocument xpsDocument = new XpsDocument(package);
// Add the package content (false=without PrintTicket).
AddPackageContent(xpsDocument, false);
// Close the package.
xpsDocument.Close();
}
' Create an XpsDocument package (without PrintTicket).
Using package1 As Package = Package.Open(packageName)
Dim xpsDocument As New XpsDocument(package1)
' Add the package content (false=without PrintTicket).
AddPackageContent(xpsDocument, False)
' Close the package.
xpsDocument.Close()
End Using
以下範例也展示了如何開啟、寫入及關閉 XpsDocument。
// Save as a WordXML document.
WordXmlSerializer.SaveToFile(fileName, flowDocument.ContentStart, flowDocument.ContentEnd);
return true;
備註
若 被 XpsDocument 開啟以進行寫入存取,資料緩衝區會寫入儲存,實體文件 Package 則會被關閉。
在 被呼叫後 Close ,此實例無法存取 XpsDocument 文件的任何部分。