private static void Main(string[] args)
{
try
{
if ((args.Length == 1) && (args[0] == "start")) // Used to start application during install
{
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = Application.ExecutablePath,
UseShellExecute = false,
WorkingDirectory = Path.GetDirectoryName (Application.ExecutablePath)
};
Process.Start (psi);
return;
}
const string projectName = "scm-notifier";
const string directoryName = projectName;
const string iniFileName = projectName + ".ini";
string appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string configPath = Path.Combine(appPath, directoryName);
string iniPath = Path.Combine(appPath, directoryName + @"\" + iniFileName);
if (!File.Exists(iniPath)) {
if (!File.Exists(configPath))
Directory.CreateDirectory(configPath);
// migrate from old config file
string oldPath = Path.Combine(appPath, "SCM_Notifier.ini");
if (File.Exists(oldPath)) {
File.Copy(oldPath, iniPath);
File.Delete(oldPath);
}
}
Config.Init(iniPath);
if (!Config.IsSettingsOK())
if (new SettingsForm().ShowDialog() != DialogResult.OK)
return;
MainForm form = new MainForm();
Thread.CurrentThread.Name = "Main";
Application.ThreadException += OnThreadException;
Application.Run (form);
lock (form)
{
if (statusThread != null)
statusThread.Abort();
}
}
catch (Exception e)
{
FatalError (e);
}
}