public static T ParseXml <T>(string path, System.Type type, bool _DoDecrypt = false) { object instance = null; //string dataPath = GameConst.Cfg_Path; //FileInfo t = new FileInfo(dataPath + "/" + filePath); FileInfo t = new FileInfo(path); if (t.Exists) { StreamReader r = t.OpenText(); string _info = r.ReadToEnd(); r.Close(); string _data = _info; if (_data.ToString() != "") { if (_DoDecrypt) { _data = KLExtend.Decrypt_DES(_data, "12345678", "12345678"); } instance = DeserializeObject(_data, type); } } return((T)instance); }
public static void SaveXml(string filePath, object obj, System.Type type, bool _DoEncrypt = false) { string _data = SerializeObject(obj, type); if (_DoEncrypt) { _data = KLExtend.Encrypt_DES(_data, "12345678", "12345678"); } StreamWriter writer; FileInfo t = new FileInfo(savePath + "/" + filePath); if (t.Exists) { t.Delete(); } writer = t.CreateText(); writer.Write(_data); writer.Close(); }