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)

アプリで、指定したファイルのリアルタイム更新を延期できます。

適用対象

こちらもご覧ください