StorageLibraryChangeTracker.Disable 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
停用 StorageFolder 或 StorageLibrary 的變更追蹤。
public:
virtual void Disable() = Disable;
void Disable();
public void Disable();
function disable()
Public Sub Disable ()
Windows 需求
裝置系列 |
Windows 10, version 2104 (已於 10.0.20348.0 引進)
|
API contract |
Windows.Foundation.UniversalApiContract (已於 v12.0 引進)
|
範例
// 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();
}
}
}
備註
如果呼叫的應用程式尚未在 StorageFolder/StorageLibrary 上呼叫 Enable,這個方法將不會執行任何動作。