Created
October 29, 2010 11:13
-
-
Save haileys/653347 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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