RemovePackage Method
Collapse the table of content
Expand the table of content

PackageStore.RemovePackage Method

Removes the Package with a specified URI from the store.

Namespace: System.IO.Packaging
Assembly: PresentationCore (in presentationcore.dll)

public static void RemovePackage (
	Uri uri
public static void RemovePackage (
	Uri uri
public static function RemovePackage (
	uri : Uri
You cannot use methods in XAML.



Exception typeCondition


packageUri is a null reference (Nothing in Visual Basic).


packageUri is an invalid package URI.

packageUri is matched to the URIs specified in the AddPackage method call.

Security Note   This method demands EnvironmentPermission for all custom Package (non-ZipPackage) types.

The following example shows how to use the RemovePackage method. For the full sample, see the Rights Managed Package Viewer Sample.

// --------------------------- 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 = null;

    // The package is closed, remove it from the store.
    if (_packageUri != null)
        _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";
        "Click 'File | Open...' to select a file to open and view.");
    rightsBlock.Text = "";

}// end:CloseDocument

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

© 2016 Microsoft