Esempio n. 1
0
 void OnAppDataChanged(object sender, FSEventStreamEventsArgs e)
 {
     foreach (var evnt in e.Events)
     {
         numDataChanged++;
         String message = numDataChanged + " " + evnt;
         System.Diagnostics.Debug.WriteLine(evnt);
         FileSystemWatcherObject o = new FileSystemWatcherObject(evnt.Path.Replace(path + "/", ""), evnt.Path, (evnt.Flags.HasFlag(FSEventStreamEventFlags.ItemIsDir) ? TargetType.Folder : TargetType.File));
         if (evnt.Flags.HasFlag(FSEventStreamEventFlags.ItemRenamed))
         {
             Event?.Invoke(FileSystemWatcherEventArgs.CreateRenamedEvent(o));
         }
         else if (evnt.Flags.HasFlag(FSEventStreamEventFlags.ItemCreated))
         {
             Event?.Invoke(FileSystemWatcherEventArgs.CreateCreatedEvent(o));
         }
         else if (evnt.Flags.HasFlag(FSEventStreamEventFlags.ItemRemoved))
         {
             Event?.Invoke(FileSystemWatcherEventArgs.CreateDeletedEvent(o));
         }
         else if (evnt.Flags.HasFlag(FSEventStreamEventFlags.ItemModified))
         {
             Event?.Invoke(FileSystemWatcherEventArgs.CreateChangedEvent(o));
         }
     }
 }
Esempio n. 2
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. 3
0
        private void OnAppDataChanged(object source, FileSystemEventArgs e)
        {
            FileSystemWatcherObject o = new FileSystemWatcherObject(e.Name, e.FullPath, (Directory.Exists(e.FullPath)) ? TargetType.Folder : TargetType.File);

            Event?.Invoke(FileSystemWatcherEventArgs.CreateChangedEvent(o));
        }