CachedFileManager 클래스

정의

앱에서 파일에 대한 실시간 업데이트를 관리할 수 있습니다.

public ref class CachedFileManager abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class CachedFileManager final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public static class CachedFileManager
Public Class CachedFileManager
상속
Object Platform::Object IInspectable CachedFileManager
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

파일 선택기 샘플에서는 CachedFileManager를 사용하여 앱이 파일 수정을 완료할 때까지 파일 업데이트를 지연하는 방법을 보여 줍니다.

if (file != null)
{
    // Prevent updates to the remote version of the file until we finish making changes and call CompleteUpdatesAsync.
    CachedFileManager.DeferUpdates(file);

    // Write to file
    await FileIO.AppendTextAsync(file, "Swift as a shadow");
    // Let Windows know that we're finished changing the file so the server app can update the remote version of the file.

    // Complete updates. (May require Windows to ask for user input.)
    FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);
    switch (status)
    {
        case FileUpdateStatus.Complete:
            // Perform additional tasks like notifying user of status
            break;

        case FileUpdateStatus.CompleteAndRenamed:
            // Perform additional tasks like notifying user of status, or storing the renamed file for future use
            break;

        default:
            // Perform additional tasks like notifying user of status
            break;
    }
}

예제에서 는 file 업데이트를 연기할 파일을 나타내는 StorageFile 을 포함하는 지역 변수입니다.

설명

이 클래스는 정적이며 인스턴스화할 수 없습니다. 대신 메서드를 직접 호출합니다.

일반적으로 Windows는 해당 파일이 변경될 때 다른 앱에서 제공하는 파일에 대한 업데이트를 암시적으로 시작합니다.  그러나 DeferUpdates를 호출하여 업데이트가 시작되는 시기를 제어할 수 있습니다. 이 메서드를 사용하는 경우 CompleteUpdatesAsync 를 호출하여 시작할 때까지 지연됩니다.

메서드

CompleteUpdatesAsync(IStorageFile)

지정된 파일에 대한 업데이트를 시작합니다. 이 메서드는 업데이트를 수행하기 위해 파일을 제공한 앱에 연결합니다.

DeferUpdates(IStorageFile)

앱에서 지정된 파일에 대한 실시간 업데이트를 연기할 수 있습니다.

적용 대상

추가 정보