private static void DeleteUserProfileShortcuts(UserProfile userProfile) { if (userProfile.DesktopShortcut) { ShortcutFunctions.DeleteUserProfileShortcut(SystemDetails.WinDesktopDir, userProfile.DesktopShortcutName); userProfile.DesktopShortcutName = null; } if (userProfile.TaskBarShortcut) { ShortcutFunctions.DeleteUserProfileShortcut(SystemDetails.WinTaskBarDir, userProfile.TaskBarShortcutName); userProfile.TaskBarShortcutName = null; } if (userProfile.QuickLaunchShortcut) { ShortcutFunctions.DeleteUserProfileShortcut(SystemDetails.WinQuickLaunchDir, userProfile.QuickLaunchShortcutName); userProfile.QuickLaunchShortcutName = null; } }
private void UpdateUserProfileList() { var userProfileList = new ObservableCollection<UserProfile>(); foreach (var di in SystemDetails.ChromeUserDataDir.GetDirectories()) { var desktopShortcut = ShortcutFunctions.FindFirstUserProfileShortcutInDir(di.Name, SystemDetails.WinDesktopDir); FileInfo taskBarShortcut = null; FileInfo quickLaunchShortcut = null; if (SystemDetails.RunningOnWin7) { taskBarShortcut = ShortcutFunctions.FindFirstUserProfileShortcutInDir(di.Name, SystemDetails.WinTaskBarDir); } else { quickLaunchShortcut = ShortcutFunctions.FindFirstUserProfileShortcutInDir(di.Name, SystemDetails.WinQuickLaunchDir); } var userProfile = new UserProfile { UserProfileName = di.Name, DesktopShortcut = desktopShortcut != null ? true : false, DesktopShortcutName = desktopShortcut != null ? Path.GetFileNameWithoutExtension(desktopShortcut.Name) : null, TaskBarShortcut = taskBarShortcut != null ? true : false, TaskBarShortcutName = taskBarShortcut != null ? Path.GetFileNameWithoutExtension(taskBarShortcut.Name) : null, QuickLaunchShortcut = quickLaunchShortcut != null ? true : false, QuickLaunchShortcutName = quickLaunchShortcut != null ? Path.GetFileNameWithoutExtension(quickLaunchShortcut.Name) : null }; userProfile.PropertyChanged += UserProfilePropertyChanged; userProfileList.Add(userProfile); } dgUserProfiles.Dispatcher.BeginInvoke( System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate { dgUserProfiles.DataContext = userProfileList; })); }