StorageLibraryChangeTracker.Enable Méthode

Définition

Surcharges

Enable()

Active le suivi des modifications pour la bibliothèque de stockage.

Enable(StorageLibraryChangeTrackerOptions)

Active le suivi des modifications pour la bibliothèque de stockage sur toutes les modifications ou sur les dernières modifications en fonction de l’ID de modification.

Enable()

Active le suivi des modifications pour la bibliothèque de stockage.

public:
 virtual void Enable() = Enable;
void Enable();
public void Enable();
function enable()
Public Sub Enable ()

S’applique à

Enable(StorageLibraryChangeTrackerOptions)

Active le suivi des modifications pour la bibliothèque de stockage sur toutes les modifications ou sur les dernières modifications en fonction de l’ID de modification.

public:
 virtual void Enable(StorageLibraryChangeTrackerOptions ^ options) = Enable;
/// [Windows.Foundation.Metadata.Overload("EnableWithOptions")]
void Enable(StorageLibraryChangeTrackerOptions const& options);
[Windows.Foundation.Metadata.Overload("EnableWithOptions")]
public void Enable(StorageLibraryChangeTrackerOptions options);
function enable(options)
Public Sub Enable (options As StorageLibraryChangeTrackerOptions)

Paramètres

Attributs

Configuration requise pour Windows

Famille d’appareils
Windows 10, version 2104 (introduit dans 10.0.20348.0)
API contract
Windows.Foundation.UniversalApiContract (introduit dans v12.0)

Exemples

// applications are expected to persist the previous value
UINT64 appsLastPersistedChangeId = StorageLibraryLastChangeId::Unknown();
StorageFolder folder = StorageFolder::GetFolderFromPathAsync(L"my folder path").get();

StorageLibraryChangeTracker tracker = folder.TryGetChangeTracker();
if (tracker != nullptr)
{
StorageLibraryChangeTrackerOptions ops;
ops.TrackChangeDetails(false);
tracker.Enable(ops);

StorageLibraryChangeReader reader = tracker.GetChangeReader();
if (reader != nullptr)
{
    UINT32 changeId = reader.GetLastChangeId();
    if ((changeId == StorageLibraryLastChangeId::Unknown())
    {
        ScanFolderSlow();
    }
    else if (changeId == 0)
    {
        // no changes in the storage folder yet, OR nothing has changed
        ProcessNormalApplicationStartup();
    }
    else if (changeId != appsLastPersistedChangeId)
    {
        // There have been new changes since we’ve last ran, process them
        appsLastPersistedChangeId = changeId;
        ScanFolderForChanges();
    }
    else
    {
        // changeId and our last persisted change id match, also normal application startup
        ProcessNormalApplicationStartup();
    }
}
}

Remarques

Pour les applications uniquement intéressées par l’ID de dernière modification, le système ne stocke pas tous les enregistrements de modification et ne gonfle pas le stockage sur l’appareil. Dans ce cas, ReadBatchAsync retourne toujours 0 enregistrements.

Voir aussi

S’applique à