From 319379665d1c25ae634055076658710a44c6eb9f Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 1 Mar 2014 16:44:34 +0000 Subject: WinGui: Add a new command line argument to the HandBrake GUI executable (--reset). This deletes all preset, user preset and settings file which should result in a full reset to defaults. Also fixed a small bug on the Add to queue button. Don't actually add an item without a destination. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6091 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/Utilities/HandBrakeApp.cs | 63 +++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 win/CS/HandBrakeWPF/Utilities/HandBrakeApp.cs (limited to 'win/CS/HandBrakeWPF/Utilities') diff --git a/win/CS/HandBrakeWPF/Utilities/HandBrakeApp.cs b/win/CS/HandBrakeWPF/Utilities/HandBrakeApp.cs new file mode 100644 index 000000000..bcdbfb430 --- /dev/null +++ b/win/CS/HandBrakeWPF/Utilities/HandBrakeApp.cs @@ -0,0 +1,63 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// A general Helper class for HandBrake GUI +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Utilities +{ + using System; + using System.Collections.Generic; + using System.IO; + using System.Linq; + + /// + /// A general Helper class for HandBrake GUI + /// + public class HandBrakeApp + { + /// + /// The reset to defaults. + /// + public static void ResetToDefaults() + { + DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\presets.xml"); + DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\user_presets.xml"); + DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\settings.xml"); + + string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\"); + DirectoryInfo info = new DirectoryInfo(tempPath); + IEnumerable logFiles = info.GetFiles("*.xml").Where(f => f.Name.StartsWith("hb_queue_recovery")); + foreach (FileInfo file in logFiles) + { + DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\" + file.Name); + } + } + + /// + /// The delete file. + /// + /// + /// The file. + /// + private static void DeleteFile(string file) + { + try + { + Console.WriteLine("Trying to deleting File: {0}", file); + if (File.Exists(file)) + { + File.Delete(file); + Console.WriteLine("File was deleted successfully"); + } + } + catch (Exception exc) + { + Console.WriteLine("Unable to Delete File: {0} {1} {2}", file, Environment.NewLine, exc); + } + } + } +} -- cgit v1.2.3