FileRevocationManager.CopyProtectionAsync(IStorageItem, IStorageItem) Method

Definition

Note

Starting in July 2022, Microsoft is deprecating Windows Information Protection (WIP) and the APIs that support WIP. Microsoft will continue to support WIP on supported versions of Windows. New versions of Windows won't include new capabilities for WIP, and it won't be supported in future versions of Windows. For more information, see Announcing sunset of Windows Information Protection.

For your data protection needs, Microsoft recommends that you use Microsoft Purview Information Protection and Microsoft Purview Data Loss Prevention. Purview simplifies the configuration set-up and provides an advanced set of capabilities.

Note

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

Copy the selective wipe protection state of a file or folder to a new file or folder.

public:
 static IAsyncOperation<bool> ^ CopyProtectionAsync(IStorageItem ^ sourceStorageItem, IStorageItem ^ targetStorageItem);
/// [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<bool> CopyProtectionAsync(IStorageItem const& sourceStorageItem, IStorageItem const& targetStorageItem);
/// [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<bool> CopyProtectionAsync(IStorageItem const& sourceStorageItem, IStorageItem const& targetStorageItem);
[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<bool> CopyProtectionAsync(IStorageItem sourceStorageItem, IStorageItem targetStorageItem);
[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<bool> CopyProtectionAsync(IStorageItem sourceStorageItem, IStorageItem targetStorageItem);
function copyProtectionAsync(sourceStorageItem, targetStorageItem)
Public Shared Function CopyProtectionAsync (sourceStorageItem As IStorageItem, targetStorageItem As IStorageItem) As IAsyncOperation(Of Boolean)

Parameters

sourceStorageItem
IStorageItem

The source item to copy the selective wipe protection status from.

targetStorageItem
IStorageItem

The target item to copy the selective wipe protection status to.

Returns

IAsyncOperation<Boolean>

IAsyncOperation<bool>

true if the copy operation was successful; otherwise false.

Attributes

Remarks

If you save a new copy of a file as the result of a "save as" operation, the selective wipe protection status is not copied with the file. To protect the file, you must call the CopyProtectionAsync method to copy the existing protection status to the new file. If you copy a protected file using the CopyAsync or CopyAndReplaceAsync methods, the selective wipe protection status is copied with the file and you do not need to call the CopyProtectionAsync method.

public async Task<bool> CopyFile(StorageFile file, StorageFolder newFolder) 
{
    bool result = false;

    try
    {
        var newFile = await file.CopyAsync(newFolder);
        result = await 
            Windows.Security.EnterpriseData.FileRevocationManager.
            CopyProtectionAsync(file, newFile);
        }
    catch (Exception e) 
    {
        // Handle exception. For example, copy already exists.
    }

    return result;
}

The CopyProtectionAsync method requires exclusive access to the file or folder being encrypted, and will fail if another process is using has a handle open to the file or folder.

Applies to

See also