Skip to content

Commit

Permalink
Minor fixes in new roaming app data storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Ginnivan committed Jan 3, 2014
1 parent 6f13b14 commit f82ed43
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/SettingsProviderNet/RoamingAppDataStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@ public RoamingAppDataStorage(string folderName)

protected override void WriteTextFile(string filename, string fileContents)
{
File.WriteAllText(GetSettingsFilename(filename), fileContents);
var settingsFolder = GetSettingsFolder();
if (!Directory.Exists(settingsFolder))
Directory.CreateDirectory(settingsFolder);
File.WriteAllText(Path.Combine(settingsFolder, filename), fileContents);
}

protected override string ReadTextFile(string filename)
{
return File.ReadAllText(GetSettingsFilename(filename));
var settingsFilename = Path.Combine(GetSettingsFolder(), filename);
return File.Exists(settingsFilename) ? File.ReadAllText(settingsFilename) : null;
}

private string GetSettingsFilename(string filename)
private string GetSettingsFolder()
{
var folderPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
var settingsFilename = Path.Combine(folderPath, folderName, filename);
var settingsFilename = Path.Combine(folderPath, folderName);
return settingsFilename;
}
}
Expand Down

0 comments on commit f82ed43

Please sign in to comment.