Beispiel #1
0
        /// <summary>
        /// 读取登录信息
        /// </summary>
        /// <returns></returns>
        public static LoginInfo Load()
        {
            LoginInfo loginInfo = new LoginInfo();

            var filePath = Path.Combine(_directoryPath, _fileName);

            if (!File.Exists(filePath))
            {
                return(null);
            }

            FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);

            byte[] arrByte = new byte[1024];
            fs.Read(arrByte, 0, 1024);
            fs.Close();
            fs.Dispose();

            int nLength = CommonHelper.byteToInt(arrByte);

            byte[] arrEncryptByte = new byte[nLength];

            for (int i = 0; i < nLength; i++)
            {
                arrEncryptByte[i] = arrByte[i + 4];
            }

            loginInfo = (LoginInfo)(Serialize.DecryptToObject(arrEncryptByte));

            return(loginInfo);
        }