Skip to content

Instantly share code, notes, and snippets.

@haileys
Created October 29, 2010 11:13
Show Gist options
  • Save haileys/653347 to your computer and use it in GitHub Desktop.
Save haileys/653347 to your computer and use it in GitHub Desktop.
public class Config
{
public string Username { get; set; }
public string Password { get; set; }
public static readonly string CfgFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "anyhubdesktop.conf");
public Config()
{
}
public static Config Load()
{
if (!F.Exists(CfgFilePath))
return new Config { Username = null };
JavaScriptSerializer jss = new JavaScriptSerializer();
return jss.Deserialize<Config>(F.ReadAllText(CfgFilePath));
}
public void Save()
{
JavaScriptSerializer jss = new JavaScriptSerializer();
string json = jss.Serialize(this);
F.WriteAllText(CfgFilePath, json);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment