共用方式為


XpsDocument.Close 方法

定義

關閉 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 實例存取檔的各個部分。

適用於