Esempio n. 1
0
        // https://docs.microsoft.com/en-us/uwp/api/windows.storage.search.istoragequeryresultbase
        // https://docs.microsoft.com/en-us/uwp/api/windows.storage.search.storageitemqueryresult
        // https://docs.microsoft.com/en-us/uwp/api/windows.storage.istorageitem
        private async void OnAppDataChanged(Windows.Storage.Search.IStorageQueryResultBase sender, object args)
        {
            FileSystemWatcherObject o = new FileSystemWatcherObject(storageFolder.DisplayName, GetPath(), TargetType.Folder);

            Event?.Invoke(FileSystemWatcherEventArgs.CreateContentChangedEvent(o));

            var newFileList = await query.GetItemsAsync();

            DiffSet diffSet = await Diff(oldFileList, newFileList);

            oldFileList = newFileList;
            foreach (IStorageItem file in diffSet.Added)
            {
                o = new FileSystemWatcherObject(file.Name, file.Path, (file.IsOfType(StorageItemTypes.Folder) ? TargetType.Folder : TargetType.File));
                Event?.Invoke(FileSystemWatcherEventArgs.CreateCreatedEvent(o));
            }
            foreach (IStorageItem file in diffSet.Deleted)
            {
                o = new FileSystemWatcherObject(file.Name, file.Path, (file.IsOfType(StorageItemTypes.Folder) ? TargetType.Folder : TargetType.File));
                Event?.Invoke(FileSystemWatcherEventArgs.CreateDeletedEvent(o));
            }
            foreach (IStorageItem file in diffSet.Changed)
            {
                o = new FileSystemWatcherObject(file.Name, file.Path, (file.IsOfType(StorageItemTypes.Folder) ? TargetType.Folder : TargetType.File));
                Event?.Invoke(FileSystemWatcherEventArgs.CreateChangedEvent(o));
            }
        }
Esempio n. 2
0
        private async void FileTracker_FilesChanged(Windows.Storage.Search.IStorageQueryResultBase sender, object e)
        {
            changing++;
            var capture = changing;
            await Task.Delay(15000);

            if (capture != changing)
            {
                return;
            }
            await FilesChangedAsync();
        }
Esempio n. 3
0
 void QueryContentsChanged(Windows.Storage.Search.IStorageQueryResultBase sender, object args)
 {
     FilesChanged?.Invoke(this, EventArgs.Empty);
 }