Esempio n. 1
0
 private void OnRenamed(object sender, RenamedEventArgs e)
 {
     if (e.Name.ToLower() == "desktop.ini")
     {
         return;
     }
     Logger.Trace($"Renamed: {e.OldFullPath} to {e.FullPath}");
     Application.Current.Dispatcher.Invoke(delegate {
         var oldParentDirectory = e.OldFullPath.Substring(0, e.OldFullPath.LastIndexOf("\\"));
         var removedAutostart   = new FolderAutoStartEntry()
         {
             Category = Category,
             Value    = e.OldName,
             Path     = oldParentDirectory,
             Date     = DateTime.Now,
         };
         Remove?.Invoke(removedAutostart);
         var newParentDirectory = e.FullPath.Substring(0, e.FullPath.LastIndexOf("\\"));
         var addedAutostart     = new FolderAutoStartEntry()
         {
             Category = Category,
             Value    = e.Name,
             Path     = newParentDirectory,
             Date     = DateTime.Now,
         };
         Add?.Invoke(addedAutostart);
     });
 }
Esempio n. 2
0
 // todo: filter duplicate calls (rename etc.)
 private void OnChanged(object sender, FileSystemEventArgs e)
 {
     if (e.ChangeType != WatcherChangeTypes.Changed ||
         e.Name.ToLower() == "desktop.ini")
     {
         return;
     }
     Logger.Trace($"Changed: {e.FullPath}");
     Application.Current.Dispatcher.Invoke(delegate {
         var parentDirectory  = e.FullPath.Substring(0, e.FullPath.LastIndexOf("\\"));
         var removedAutostart = new FolderAutoStartEntry()
         {
             Category = Category,
             Value    = e.Name,
             Path     = parentDirectory,
             Date     = DateTime.Now,
         };
         Remove?.Invoke(removedAutostart);
         var addedAutostart = new FolderAutoStartEntry()
         {
             Category = Category,
             Value    = e.Name,
             Path     = parentDirectory,
             Date     = DateTime.Now,
         };
         Add?.Invoke(addedAutostart);
     });
 }
        // todo: read target of links?
        // read sub directories?
        public IList <AutoStartEntry> GetCurrentAutoStarts()
        {
            Logger.Trace("GetCurrentAutoStarts called");
            var ret = new List <AutoStartEntry>();

            string[] filePaths = Directory.GetFiles(BasePath);
            foreach (var filePath in filePaths)
            {
                var fileName = filePath.Substring(filePath.LastIndexOf("\\") + 1);
                if (fileName.ToLower() == "desktop.ini")
                {
                    continue;
                }
                var entry = new FolderAutoStartEntry()
                {
                    Date     = DateTime.Now,
                    Category = Category,
                    Path     = BasePath,
                    Value    = fileName,
                };
                ret.Add(entry);
            }
            return(ret);
        }