StorageLibraryLastChangeId Classe

Definizione

Consente di tenere traccia delle modifiche in base a un valore univoco che rappresenta l'ultima modifica elaborata dal servizio di indicizzazione per l'oggetto StorageFolder o StorageLibrary specificato.

public ref class StorageLibraryLastChangeId sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 720896)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class StorageLibraryLastChangeId final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 720896)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class StorageLibraryLastChangeId
Public NotInheritable Class StorageLibraryLastChangeId
Ereditarietà
Object Platform::Object IInspectable StorageLibraryLastChangeId
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();
    }
}
}

Proprietà

Unknown

Restituito quando il journal USN esegue il overflow e il servizio non può rimanere aggiornato con le modifiche o c'è un altro motivo per cui non è possibile calcolare l'ID modifica.

Si applica a

Vedi anche