Skip to content

Commit

Permalink
Migrate from old configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
pocorall committed Aug 9, 2015
1 parent 404e988 commit 8e172a7
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions SCM_Notifier/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1366,17 +1366,24 @@ private static void Main (string[] args)
const string projectName = "scm-notifier";
const string directoryName = projectName;
const string iniFileName = projectName + ".ini";
if (File.Exists (iniFileName))
Config.Init (iniFileName);
else
{
// MW: Ensure INI file is created in subdirectory of AppData folder
if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), directoryName)))
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), directoryName));

Config.Init(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), directoryName + @"\" + iniFileName));
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;
Expand Down

0 comments on commit 8e172a7

Please sign in to comment.