public override bool TryRemoveImage(string fileName)
        {
            if (PendingIds.Contains(fileName))
            {
                PendingIds.Remove(fileName);
            }

            string fullPath = Path.Combine(Watcher.Path, fileName);

            return(TryRemoveFile(fullPath));
        }
        public override bool TryGetImage(string fileName, out byte[] outImageBytes)
        {
            if (PendingIds.Contains(fileName))
            {
                PendingIds.Remove(fileName);
            }

            string fullPath = Path.Combine(Watcher.Path, fileName);

            return(TryGetFile(fullPath, out outImageBytes));
        }
        private void OnDeleted(object source, FileSystemEventArgs e)
        {
            string fileName = e.Name;

            if (PendingIds.Contains(fileName))
            {
                PendingIds.Remove(fileName);
            }

            FileDeleted?.Invoke(fileName);
        }
        private void OnRenamed(object source, RenamedEventArgs e)
        {
            string oldFileName = e.OldName;
            string newFileName = e.Name;

            if (PendingIds.Contains(oldFileName))
            {
                PendingIds.Remove(oldFileName);
            }

            // This will place the renamed file at the end of the list
            PendingIds.Add(newFileName);
            FileRenamed?.Invoke(oldFileName, newFileName);
        }
        private void LoadExistingFiles(string path, string filter)
        {
            DirectoryInfo dir = new DirectoryInfo(path);

            FileSystemInfo[] existingFiles = dir.GetFileSystemInfos(filter);
            Array.Sort <FileSystemInfo>(existingFiles,
                                        delegate(FileSystemInfo a, FileSystemInfo b)
            {
                return(a.LastWriteTime.CompareTo(b.LastWriteTime));
            });

            foreach (FileSystemInfo file in existingFiles)
            {
                PendingIds.Add(file.Name);
            }
        }
 private void OnCreated(object source, FileSystemEventArgs e)
 {
     PendingIds.Add(e.Name);
     ImageAvailable(e.Name);
 }