Example #1
0
        public static WatchLog Create(string path, FileSystemEventArgs e)
        {
            var log = new WatchLog();

            log.Path      = path;
            log.Name      = System.IO.Path.GetFileName(path);
            log.EventName = e.ChangeType.ToString();
            log.FilePath  = e.FullPath;
            log.FileName  = e.Name;
            log.Date      = DateTime.Now;

            if (e is RenamedEventArgs renamed)
            {
                log.BeforeFilePath = renamed.OldFullPath;
                log.BeforeFileName = renamed.OldName;
            }
            else
            {
                log.BeforeFilePath = string.Empty;
                log.BeforeFileName = string.Empty;
            }

            return(log);
        }
Example #2
0
        private void OnDeleted(object sender, FileSystemEventArgs e)
        {
            WatchLog log = WatchLog.Create(Path, e);

            Dispatcher.Invoke(() => Logs.Insert(0, log));
        }
Example #3
0
        private void OnRenamed(object sender, RenamedEventArgs e)
        {
            WatchLog log = WatchLog.Create(Path, e);

            Dispatcher.Invoke(() => Logs.Insert(0, log));
        }