Share via


FileRevocationManager.GetStatusAsync(IStorageItem) メソッド

定義

Note

2022 年 7 月以降、Microsoft は Windows Information Protection (WIP) と WIP をサポートする API を非推奨にしています。 Microsoft は、サポートされているバージョンの Windows で WIP を引き続きサポートします。 Windows の新しいバージョンには WIP の新機能は含まれません。また、今後のバージョンの Windows ではサポートされません。 詳細については、「Windows Information Protectionの終了を発表する」を参照してください。

データ保護のニーズに合わせて、Microsoft Purview 情報保護Microsoft Purview データ損失防止を使用することをお勧めします。 Purview を使用すると、構成のセットアップが簡略化され、高度な機能セットが提供されます。

Note

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 メソッドの一般的な用途は、保護されたファイルを削除するタイミングを決定することです。 たとえば、保護されたファイルが取り消されると、ファイルの内容にアクセスしようとすると、"Access is denied" 例外が発生します。 その例外が発生した場合は、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();
    }
}

適用対象

こちらもご覧ください