共用方式為


FileRevocationManager.CopyProtectionAsync(IStorageItem, IStorageItem) 方法

定義

注意

從 2022 年 7 月開始,Microsoft 即將淘汰 Windows 資訊保護 (WIP) ,以及支援 WIP 的 API。 Microsoft 將繼續在支援的 Windows 版本上支援 WIP。 新版本的 Windows 不會包含 WIP 的新功能,且未來版本的 Windows 不支援此功能。 如需詳細資訊,請參閱宣佈 Windows 資訊保護的終止

針對資料保護需求,Microsoft 建議您使用Microsoft Purview 資訊保護Microsoft Purview 資料外洩防護。 Purview 簡化了組態設定,並提供一組進階的功能。

注意

fileRevocationManager在Windows 10之後可能無法使用版本。 請改用 FileProtectionManager

將檔案或資料夾的選擇性抹除保護狀態複製到新的檔案或資料夾。

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)

參數

sourceStorageItem
IStorageItem

要複製選擇性抹除保護狀態的來源專案。

targetStorageItem
IStorageItem

要複製選擇性抹除保護狀態的目標專案。

傳回

如果複製作業成功,則為true;否則為 false

屬性

備註

如果您將檔案的新複本儲存為「另存新檔」作業的結果,則不會使用檔案複製選擇性抹除保護狀態。 若要保護檔案,您必須呼叫 CopyProtectionAsync 方法來將現有的保護狀態複製到新的檔案。 如果您使用 CopyAsyncCopyAndReplaceAsync 方法來複製受保護的檔案,則會使用檔案複製選擇性抹除保護狀態,而您不需要呼叫 CopyProtectionAsync 方法。

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;
}

CopyProtectionAsync 方法需要對正在加密的檔案或資料夾進行獨佔存取,如果另一個進程正在使用的控制碼開啟檔案或資料夾,將會失敗。

適用於

另請參閱