SunSync.Models.Account.TryLoadAccount C# (CSharp) Method

TryLoadAccount() public static method

load account settings from local file if exists return empty object if none
public static TryLoadAccount ( ) : Account
return Account
        public static Account TryLoadAccount()
        {
            Account acct = new Account();
            string myDocPath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string accPath = System.IO.Path.Combine(myDocPath, "qsunsync", "account.json");
            if (File.Exists(accPath))
            {
                string accData = "";
                using (StreamReader sr = new StreamReader(accPath, Encoding.UTF8))
                {
                    accData = sr.ReadToEnd();
                }
                try
                {
                    acct = JsonConvert.DeserializeObject<Account>(accData);
                }
                catch (Exception ex)
                {
                    Log.Error("parse account info failed, " + ex.Message);
                }
            }
            return acct;
        }