CachedFileUpdater CachedFileUpdater CachedFileUpdater CachedFileUpdater CachedFileUpdater Class

Definition

Manages files so that they can be updated in real-time by an app that participates in the Cached File Updater contract.

public : static class CachedFileUpdater
static struct winrt::Windows::Storage::Provider::CachedFileUpdater
public static class CachedFileUpdater
Public Shared Class CachedFileUpdater
// This class does not provide a public constructor.
Attributes

Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The File picker contracts sample demonstrates how to set update information for a file in its TargetFileRequested event handler.


private async void OnTargetFileRequested(FileSavePickerUI sender, TargetFileRequestedEventArgs e)
{
    // Handle the TargetFileRequested event on the background thread on which it was raised

    // Requesting a deferral allows the app to call another asynchronous method and complete the request at a later time
    var deferral = e.Request.GetDeferral();

    StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(sender.FileName, CreationCollisionOption.ReplaceExisting);

    // Set update info for the file
    CachedFileUpdater.SetUpdateInformation(file, "CachedFile", ReadActivationMode.NotNeeded, WriteActivationMode.AfterWrite, CachedFileOptions.RequireUpdateOnAccess);

    // Assign the resulting file to the targetFile property and complete the deferral to indicate success  
    e.Request.TargetFile = file;
    deferral.Complete();
}
function onTargetFileRequested(e) {
    var deferral;
    deferral = e.request.getDeferral();

    Windows.Storage.ApplicationData.current.localFolder.createFileAsync(fileSavePickerUI.fileName, Windows.Storage.CreationCollisionOption.replaceExisting).done(
        function (file) {
            // Set update info for the file
            Windows.Storage.Provider.CachedFileUpdater.setUpdateInformation(
                file,
                "CachedFile",
                Windows.Storage.Provider.ReadActivationMode.notNeeded,
                Windows.Storage.Provider.WriteActivationMode.afterWrite,
                Windows.Storage.Provider.CachedFileOptions.requireUpdateOnAccess
            );

            // Assign the resulting file to the targetFile property and complete the deferral to indicate success
            e.request.targetFile = file;
            deferral.complete();
        }, function () {
            // Set the targetFile property to null and complete the deferral to indicate failure
            e.request.targetFile = null;
            deferral.complete();
        }
    );
};

Remarks

Access methods in this class statically.

Methods

SetUpdateInformation(IStorageFile, String, ReadActivationMode, WriteActivationMode, CachedFileOptions) SetUpdateInformation(IStorageFile, String, ReadActivationMode, WriteActivationMode, CachedFileOptions) SetUpdateInformation(IStorageFile, String, ReadActivationMode, WriteActivationMode, CachedFileOptions) SetUpdateInformation(IStorageFile, String, ReadActivationMode, WriteActivationMode, CachedFileOptions) SetUpdateInformation(IStorageFile, String, ReadActivationMode, WriteActivationMode, CachedFileOptions)

Configures update policies for a local file.

See also