PackageStore.RemovePackage(Uri) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將具有指定之 URI 的 Package 從存放區中移除。
public:
static void RemovePackage(Uri ^ uri);
public static void RemovePackage (Uri uri);
static member RemovePackage : Uri -> unit
Public Shared Sub RemovePackage (uri As Uri)
參數
- uri
- Uri
要移除之套件的統一資源識別項 (URI)。
例外狀況
packageUri
為 null
。
packageUri
是無效的套件 URI。
範例
下列範例會示範如何使用 RemovePackage 方法。
// --------------------------- CloseDocument --------------------------
/// <summary>
/// Closes the document currently displayed in
/// the DocumentViewer control.</summary>
public void CloseDocument()
{
if (_xpsFile != null)
{
ShowStatus("Closing '" + Filename(_xpsFile) + "'");
DocViewer.Document = null;
_xpsFile = null;
}
// If the package is open, close it.
if (_xpsPackage != null)
{
_xpsPackage.Close();
_xpsPackage = null;
}
// The package is closed, remove it from the store.
if (_packageUri != null)
{
PackageStore.RemovePackage(_packageUri);
_packageUri = null;
}
// Disable document-related selections when there's no document.
menuFileClose.IsEnabled = false;
menuFilePrint.IsEnabled = false;
menuViewIncreaseZoom.IsEnabled = false;
menuViewDecreaseZoom.IsEnabled = false;
this.Title = "RightsManagedPackageViewer SDK Sample";
ShowPrompt(
"Click 'File | Open...' to select a file to open and view.");
rightsBlock.Text = "";
}// end:CloseDocument
' --------------------------- CloseDocument --------------------------
''' <summary>
''' Closes the document currently displayed in
''' the DocumentViewer control.</summary>
Public Sub CloseDocument()
If _xpsFile IsNot Nothing Then
ShowStatus("Closing '" & Filename(_xpsFile) & "'")
DocViewerProperty.Document = Nothing
_xpsFile = Nothing
End If
' If the package is open, close it.
If _xpsPackage IsNot Nothing Then
_xpsPackage.Close()
_xpsPackage = Nothing
End If
' The package is closed, remove it from the store.
If _packageUri IsNot Nothing Then
PackageStore.RemovePackage(_packageUri)
_packageUri = Nothing
End If
' Disable document-related selections when there's no document.
menuFileClose.IsEnabled = False
menuFilePrint.IsEnabled = False
menuViewIncreaseZoom.IsEnabled = False
menuViewDecreaseZoom.IsEnabled = False
Me.Title = "RightsManagedPackageViewer SDK Sample"
ShowPrompt("Click 'File | Open...' to select a file to open and view.")
rightsBlock.Text = ""
End Sub
備註
packageUri
會比對方法呼叫中指定的 AddPackage URI。
安全性注意事項 此方法會要求 EnvironmentPermission 所有自訂 Package (非ZipPackage) 類型。