Example #1
0
 public BrokenShortcutUserControl(BrokenShortcut brokenShortcutObject)
 {
     InitializeComponent();
     this.TargetPath.Content   = brokenShortcutObject.TargetPath;
     this.ShortcutPath.Content = brokenShortcutObject.ShortcutPath;
     BrokenShortcutObject      = brokenShortcutObject;
 }
Example #2
0
        public static HashSet <BrokenShortcut> GetAllBrokenShortcuts(string directoryToCheck, ObservableCollection <BrokenShortcutUserControl> observableCollection)
        {
            HashSet <BrokenShortcut> brokenShortcuts = new HashSet <BrokenShortcut>();

            string[] subdirectories = Directory.GetDirectories(directoryToCheck);
            foreach (string subdir in subdirectories)
            {
                brokenShortcuts.UnionWith(GetAllBrokenShortcuts(subdir, observableCollection));
            }

            string[] files = Directory.GetFiles(directoryToCheck, "*.lnk");
            foreach (string file in files)
            {
                BrokenShortcut brokenShortcut = IsBrokenShortcut(file);
                if (brokenShortcut != null)
                {
                    Application.Current.Dispatcher.BeginInvoke(
                        DispatcherPriority.Background,
                        new Action(() => observableCollection.Add(new BrokenShortcutUserControl(brokenShortcut))));
                    brokenShortcuts.Add(brokenShortcut);
                }
            }

            return(brokenShortcuts);
        }