public static void SaveShortcutsToRegistry() { //删除 //先删除原来的所有文件 var oldSettings = new AppSettingCollection(); foreach (var oldItem in oldSettings) { Console.WriteLine("删除" + oldItem.AppName); Registry.LocalMachine.DeleteSubKey(GetSubRegistryKey(oldItem), false); } //删除 Shortcut 文件 if (Directory.Exists(ShortcutDir)) { Directory.Delete(ShortcutDir, true); } //重建 //建立新的文件夹 Directory.CreateDirectory(ShortcutDir); var newAppSettings = new AppSettingCollection(TempDataFileName); foreach (var item in newAppSettings) { //创建 Shortcut 文件 var shortcut = CreateShortcut(item); if (shortcut != null) { Console.WriteLine("创建" + item.AppName); var key = GetSubRegistryKey(item); Registry.LocalMachine.CreateSubKey(key).SetValue(string.Empty, shortcut); } } }
private void LoadData() { this._allData = new AppSettingCollection(); this._allDataView = CollectionViewSource.GetDefaultView(this._allData); this.DataContext = this._allDataView; this.ResetSearchState(); this._allDataView.CollectionChanged += (o, e) => this.ResetSearchState(); }