다음을 통해 공유


PackageStore.RemovePackage(Uri) 메서드

정의

저장소에서 지정된 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(Uniform Resource Identifier)입니다.

예외

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 는 메서드 호출에 지정된 URI와 AddPackage 일치합니다.

보안 참고 사항 이 메서드는 EnvironmentPermission 모든 사용자 지정 Package (비ZipPackage) 형식을 요구합니다.

적용 대상

추가 정보