Bagikan melalui


CachedFileUpdater Kelas

Definisi

Mengelola file sehingga dapat diperbarui secara real-time oleh aplikasi yang berpartisipasi dalam kontrak Cache 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
Warisan
Object Platform::Object IInspectable CachedFileUpdater
Atribut

Persyaratan Windows

Rangkaian perangkat
Windows 10 (diperkenalkan dalam 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v1.0)

Contoh

Sampel kontrak pemilih File menunjukkan cara mengatur informasi pembaruan untuk file di penanganan aktivitas TargetFileRequested- nya.

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

Keterangan

Metode akses di kelas ini secara statis.

Metode

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

Mengonfigurasi kebijakan pembaruan untuk file lokal.

Berlaku untuk

Lihat juga