blob: bcdbfb430cbbc9438b289f66821543e1e1e0676f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="HandBrakeApp.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
// A general Helper class for HandBrake GUI
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Utilities
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
/// <summary>
/// A general Helper class for HandBrake GUI
/// </summary>
public class HandBrakeApp
{
/// <summary>
/// The reset to defaults.
/// </summary>
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<FileInfo> 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);
}
}
/// <summary>
/// The delete file.
/// </summary>
/// <param name="file">
/// The file.
/// </param>
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);
}
}
}
}
|