Skip to main content
CachedFileUpdater class

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

Syntax


var cachedFileUpdater = Windows.Storage.Provider.CachedFileUpdater;

public static class CachedFileUpdater

Public NotInheritable Class CachedFileUpdater

public ref class CachedFileUpdater abstract sealed 

Members

The CachedFileUpdater class has these types of members:

Methods

The CachedFileUpdater class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
SetUpdateInformation Configures update policies for a local file.

 

Remarks

Access methods in this class statically.

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

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0 [for Xbox, see UWP features that aren't yet supported on Xbox]

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Storage.Provider
Windows::Storage::Provider [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.Storage.Provider
Windows::Storage::Provider [C++]

Metadata

Windows.winmd

Attributes

[ MarshalingBehavior(Agile)]
[ Version(0x06020000)]

See also

Object
File picker provider sample (Windows 10)