Exemplo n.º 1
0
        /// <summary>
        /// 保存到文件
        /// </summary>
        public static void Save()
        {
            try
            {
                var json = SerializeHelper.Serialize(_list);

                var str = AESTool.Encrypt(json, "yswenli", false);

                var filePath = Path.Combine(GetCurrentPath("Config"), "userconfig.json");

                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                File.AppendAllText(filePath, str);
            }
            catch (Exception ex)
            {
                LogHelper.Error("UserHelper.Save", ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 读取配置列表
        /// </summary>
        /// <returns></returns>
        public static List <User> ReadList()
        {
            var filePath = Path.Combine(GetCurrentPath("Config"), "userconfig.json");

            if (File.Exists(filePath))
            {
                var json = File.ReadAllText(filePath);

                if (!string.IsNullOrEmpty(json))
                {
                    var str = AESTool.Decrypt(json, "yswenli", false);

                    _list = SerializeHelper.Deserialize <List <User> >(str);

                    if (_list != null && _list.Count > 0)
                    {
                        return(_list);
                    }
                }
            }

            return(new List <User>());
        }