Files
WOL-Manager/WoL-Manager v0.1/Program.cs
T
2017-10-26 20:11:00 +02:00

88 lines
2.0 KiB
C#
Executable File

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml;
namespace WoL_Manager
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
string fileName1 = "hosts.xml";
string fileName2 = "hosts.dtd";
string fileName3 = "settings.xml";
string fileName4 = "settings.dtd";
ManagerSettings.createDTD(fileName4);
if (System.IO.File.Exists(fileName3))
{
bool result;
try
{
result = ManagerSettings.readFromFile(fileName3);
}
catch (Exception)
{
result = false;
}
if (result == false)
{
System.Windows.Forms.MessageBox.Show("Parse Error while reading settings-file!");
try
{
System.IO.File.Delete(fileName3);
}
catch (Exception)
{
System.Windows.Forms.MessageBox.Show("Couldn't delete file 'settings.xml'!\nPlease delete this file manually.");
return;
}
}
}
Host.createDTD(fileName2);
if (System.IO.File.Exists(fileName1))
{
bool result;
try
{
result = Host.readFromFile(fileName1);
}
catch (Exception)
{
result = false;
}
if (result == false)
{
System.Windows.Forms.MessageBox.Show("Parse Error while reading host-file!");
try
{
System.IO.File.Delete(fileName1);
}
catch (Exception)
{
System.Windows.Forms.MessageBox.Show("Couldn't delete file 'hosts.xml'!\nPlease delete this file manually.");
return;
}
Host.clearList();
}
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
MainWindow apps = new MainWindow();
Host.Parent = apps;
Application.Run(apps);
Host.writeToFile(fileName1);
ManagerSettings.writeToFile(fileName3);
apps.deletePingThreads();
Application.Exit();
}
}
}