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
|
using System;
using System.Configuration;
using System.IO;
namespace TestSettings
{
class Program
{
/// <summary>
/// Der Haupteinstiegspunkt für die Anwendung.
/// </summary>
/// <param name="args">
/// Befehlszeilenargumente.
/// <para>
/// Werte:
/// <list type="table">
/// <listheader>
/// <term>Argument</term>
/// <description>Befehlszeilenargument</description>
/// </listheader>
/// <item>
/// <term><c>-del</c></term>
/// <description>löscht die user.confg</description>
/// </item>
/// </list>
/// </para>
/// </param>
static void Main(string[] args)
{
if (args.Length > 0 && args[0] == "-del")
{
// user.config holen:
Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.PerUserRoamingAndLocal);
// Pfad ermitteln:
DirectoryInfo di = new DirectoryInfo(config.FilePath);
// Ordner und übergeordneten Ordner der user.config
// löschen -> durch true werden alle Dateien gelöscht.
di.Parent.Parent.Delete(true);
// Programm verlassen:
return;
}
Console.WriteLine("Normale Programmausführung");
Console.ReadKey();
}
}
}
|