FileRevocationManager.GetStatusAsync(IStorageItem) FileRevocationManager.GetStatusAsync(IStorageItem) FileRevocationManager.GetStatusAsync(IStorageItem) FileRevocationManager.GetStatusAsync(IStorageItem) FileRevocationManager.GetStatusAsync(IStorageItem) Method

Definition

Note

FileRevocationManager may be unavailable for releases after Windows 10. Instead, use FileProtectionManager.

Note

Windows Information Protection (WIP) policy cannot be applied on Windows 10, version 1511 (build 10586) or earlier.

Gets the selective wipe protection status for a file or folder.

public : static IAsyncOperation<FileProtectionStatus> GetStatusAsync(IStorageItem storageItem)
static IAsyncOperation<FileProtectionStatus> GetStatusAsync(IStorageItem storageItem) const;
public static IAsyncOperation<FileProtectionStatus> GetStatusAsync(IStorageItem storageItem)
Public Shared Function GetStatusAsync(storageItem As IStorageItem) As IAsyncOperation(Of FileProtectionStatus)
Windows.Security.EnterpriseData.FileRevocationManager.getStatusAsync(storageItem).done( /* Your success and error handlers */ );

Parameters

storageItem
IStorageItem IStorageItem IStorageItem

The file or folder to get the selective wipe protection status for.

Returns

An aysnchronous operation that retrieves the selective wipe protection status for the storageItem.

Remarks

You can use the GetStatusAsync method to determine the Selective Wipe protection status of a file or folder. This will tell you if a file is protected or not, if a file is protected by another user on the computer, and so on. A common use of the GetStatusAsync method is to determine when a protected file should be deleted. For example, when a protected file is revoked, an attempt to access the file contents will result in an "Access is denied" exception. When you encounter that exception, you can use the GetStatusAsync method to determine if the file has been revoked by Selective Wipe and then delete the file if it has, as shown in the following example.

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();
    }
}
var appRootFolder = Windows.Storage.ApplicationData.current;
var enterpriseIdentity = "example.com";
var accessDeniedHResult = -2147024891;  // Access Denied (0x80070005)
function getFileContents(filePath) {
    var stream;
    var file;

    Windows.Storage.StorageFile.getFileFromPathAsync(filePath).then(
        function (f) {
            file = f;
            file.openReadAsync().then(
                function (s) {
                    stream = s;
                    return stream;
                },
                function (err) {
                    if (err.number == accessDeniedHResult) {
                        // Delete file if it has been revoked.
                        selectiveWipeCleanup(file);
                    }
                });
        });

    return null;
}

// Delete items revoked by Selective Wipe.
function selectiveWipeCleanup(file) {
    Windows.Security.EnterpriseData.FileRevocationManager.
        getStatusAsync(file).then(
            function (status) {
                if (status == 
                    Windows.Security.EnterpriseData.FileProtectionStatus.revoked) {
                        file.deleteAsync();
                }
        });

}

See also