1. 程式人生 > >C# 使用配置資訊儲存程式配置

C# 使用配置資訊儲存程式配置

開機載入配置: string base64=Properties.Settings.Default.KEY; KEY_S key = B64Serialize.StringToObject<KEY_S>(base64); KEY.appkey = key.appkey; KEY.password = key.password;

配置類: [Serializable] class KEY_S { public string appkey = “”; public string password = “”; }

更新配置資訊: string base64 = “”; KEY_S key = new KEY_S(); key.appkey = txt_key.Text; key.password = txt_pwd.Text; base64 = B64Serialize.ObjectToString<KEY_S>(key); KEY.appkey = key.appkey; KEY.password = key.password;

        Properties.Settings.Default.KEY = base64;
        Properties.Settings.Default.Save();