Share via


StorageLibraryChangeTracker.Enable Metodo

Definizione

Overload

Enable()

Abilita il rilevamento delle modifiche per la libreria di archiviazione.

Enable(StorageLibraryChangeTrackerOptions)

Abilita il rilevamento delle modifiche per la libreria di archiviazione in tutte o le modifiche più recenti in base all'ID modifica.

Enable()

Abilita il rilevamento delle modifiche per la libreria di archiviazione.

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

Si applica a

Enable(StorageLibraryChangeTrackerOptions)

Abilita il rilevamento delle modifiche per la libreria di archiviazione in tutte o le modifiche più recenti in base all'ID modifica.

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)

Parametri

Attributi

Requisiti Windows

Famiglia di dispositivi
Windows 10, version 2104 (è stato introdotto in 10.0.20348.0)
API contract
Windows.Foundation.UniversalApiContract (è stato introdotto in v12.0)

Esempio

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

Commenti

Per le applicazioni interessate solo all'ultimo ID di modifica, il sistema non archivierà tutti i record delle modifiche e bloat la risorsa di archiviazione nel dispositivo. In questo caso, ReadBatchAsync restituirà sempre 0 record.

Vedi anche

Si applica a