다음을 통해 공유


FileRevocationManager.GetStatusAsync(IStorageItem) 메서드

정의

참고

2022년 7월부터 Microsoft는 WIP(Windows Information Protection) 및 WIP를 지원하는 API를 더 이상 사용하지 않습니다. Microsoft는 지원되는 Windows 버전에서 WIP를 계속 지원할 것입니다. 새 버전의 Windows는 WIP에 대한 새로운 기능을 포함하지 않으며 이후 버전의 Windows에서는 지원되지 않습니다. 자세한 내용은 Windows Information Protection 일몰 발표를 참조하세요.

데이터 보호 요구 사항에 따라 Microsoft Purview Information ProtectionMicrosoft Purview 데이터 손실 방지 사용하는 것이 좋습니다. Purview는 구성 설정을 간소화하고 고급 기능 집합을 제공합니다.

참고

FileRevocationManager는 Windows 10 후 릴리스에 사용할 수 없습니다. 대신 FileProtectionManager를 사용합니다.

파일 또는 폴더에 대한 선택적 초기화 보호 상태 가져옵니다.

public:
 static IAsyncOperation<FileProtectionStatus> ^ GetStatusAsync(IStorageItem ^ storageItem);
/// [Windows.Foundation.Metadata.Deprecated("FileRevocationManager might be unavailable after Windows 10. Instead, use FileProtectionManager.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, Windows.Security.EnterpriseData.EnterpriseDataContract)]
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<FileProtectionStatus> GetStatusAsync(IStorageItem const& storageItem);
/// [Windows.Foundation.Metadata.RemoteAsync]
/// [Windows.Foundation.Metadata.Deprecated("FileRevocationManager might be unavailable after Windows 10. Instead, use FileProtectionManager.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.Security.EnterpriseData.EnterpriseDataContract")]
 static IAsyncOperation<FileProtectionStatus> GetStatusAsync(IStorageItem const& storageItem);
[Windows.Foundation.Metadata.Deprecated("FileRevocationManager might be unavailable after Windows 10. Instead, use FileProtectionManager.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, typeof(Windows.Security.EnterpriseData.EnterpriseDataContract))]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<FileProtectionStatus> GetStatusAsync(IStorageItem storageItem);
[Windows.Foundation.Metadata.RemoteAsync]
[Windows.Foundation.Metadata.Deprecated("FileRevocationManager might be unavailable after Windows 10. Instead, use FileProtectionManager.", Windows.Foundation.Metadata.DeprecationType.Deprecate, 65536, "Windows.Security.EnterpriseData.EnterpriseDataContract")]
public static IAsyncOperation<FileProtectionStatus> GetStatusAsync(IStorageItem storageItem);
function getStatusAsync(storageItem)
Public Shared Function GetStatusAsync (storageItem As IStorageItem) As IAsyncOperation(Of FileProtectionStatus)

매개 변수

storageItem
IStorageItem

선택적 초기화 보호 상태 가져올 파일 또는 폴더입니다.

반환

storageItem에 대한 선택적 초기화 보호 상태 검색하는 비동기 작업입니다.

특성

설명

GetStatusAsync 메서드를 사용하여 파일 또는 폴더의 선택적 초기화 보호 상태 확인할 수 있습니다. 이렇게 하면 파일이 보호되는지 여부, 컴퓨터의 다른 사용자가 파일을 보호하는지 여부 등이 표시됩니다. GetStatusAsync 메서드의 일반적인 사용은 보호된 파일을 삭제해야 하는 시기를 결정하는 것입니다. 예를 들어 보호된 파일이 해지되면 파일 내용에 액세스하려고 하면 "액세스가 거부됨" 예외가 발생합니다. 이 예외가 발생하면 GetStatusAsync 메서드를 사용하여 선택적 초기화에 의해 파일이 해지되었는지 확인한 다음, 다음 예제와 같이 파일이 있는 경우 파일을 삭제할 수 있습니다.

ApplicationData appRootFolder = ApplicationData.Current;
string enterpriseIdentity = "example.com";
int AccessDeniedHResult = -2147024891;  // Access Denied (0x80070005)
private async Task<IRandomAccessStream> GetFileContents(string filePath)
{
    IRandomAccessStream stream = null;
    StorageFile file = null;

    try
    {
        file = await StorageFile.GetFileFromPathAsync(filePath);
        stream = await file.OpenReadAsync();
    }
    catch (UnauthorizedAccessException e)
    {
        if (e.HResult == AccessDeniedHResult)
        {
            // Delete file if it has been revoked.
            SelectiveWipeCleanup(file);
        }

        return null;
    }

    return stream;
}

// Delete items revoked by Selective Wipe.
private async void SelectiveWipeCleanup(StorageFile file)
{
    var status = await Windows.Security.EnterpriseData.FileRevocationManager.GetStatusAsync(file);
    if (status == Windows.Security.EnterpriseData.FileProtectionStatus.Revoked)
    {
        await file.DeleteAsync();
    }
}

적용 대상

추가 정보