public static void SavePathToTempFile(IEnumerable <PathEntry> items) { var path = PathReader.ItemsToPathString(items); var fullPath = Path.Combine(AppDataPath.AppDataDirPath, TempFileName); var file = new StreamWriter(fullPath); file.Write(path); file.Close(); }
private void Reload() { var itemList = PathReader.ReadPath(PathType); var disabledItemList = DisabledItems.ReadDisabledItems(PathType); var items = itemList.Concat(disabledItemList) .Distinct(new PathEntry.PathEqualityComparer()); Items.Clear(); foreach (var item in items) { Items.Add(item); } }
private void Save_Click(object sender, RoutedEventArgs e) { PathReader.SavePathToRegistry(PathType, PathReader.ItemsToPathString(Items)); if (PathType == PathType.User) { PathReader.SavePathToRegistry(PathType, PathReader.ItemsToPathString(Items)); } else { BatchMode.UseBatchModeAsAdmin(Items); } DisabledItems.SaveDisabledItems(PathType, Items); PathBox.Focus(); }
public static void SavePathFromTempFile() { try { var fullPath = Path.Combine(AppDataPath.AppDataDirPath, TempFileName); var file = new StreamReader(fullPath); var path = file.ReadToEnd(); PathReader.SavePathToRegistry(PathType.System, path); file.Close(); } catch { MessageBox.Show("Непредвиденная ошибка PATH."); } finally { File.Delete(TempFileName); } }