Condividi tramite


CachedFileUpdater Classe

Definizione

Gestisce i file in modo che possano essere aggiornati in tempo reale da un'app che partecipa al contratto Cached File Updater.

public ref class CachedFileUpdater abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class CachedFileUpdater final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public static class CachedFileUpdater
Public Class CachedFileUpdater
Ereditarietà
Object Platform::Object IInspectable CachedFileUpdater
Attributi

Requisiti Windows

Famiglia di dispositivi
Windows 10 (è stato introdotto in 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (è stato introdotto in v1.0)

Esempio

L'esempio contratti di selezione file illustra come impostare le informazioni di aggiornamento per un file nel relativo gestore eventi TargetFileRequested.

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

Commenti

Accedere ai metodi in questa classe in modo statico.

Metodi

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

Configura i criteri di aggiornamento per un file locale.

Si applica a

Vedi anche