Example #1
0
        /// <summary>
        /// 加载文件
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        static public bool Load(ref AppParam param)
        {
            FileStream fs = null;

            try
            {
                string strDir = GetCurDir();

                fs = new FileStream(strDir + @"\FileSevice.dat", FileMode.Open);

                BinaryFormatter formatter = new BinaryFormatter();                //使用BinaryFormatter进行反序列化
                param._saveParam = (AppParam.SaveParam)formatter.Deserialize(fs); //反序列化文件路径
            }
            catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
            return(false);
        }
Example #2
0
        /// <summary>
        /// 将上传文件路径保存到文件中
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        static public bool Save(AppParam param)
        {
            FileStream fs = null;

            try
            {
                BinaryFormatter formatter = new BinaryFormatter();//使用BinaryFormatter进行序列化
                string          strDir    = GetCurDir();

                fs = new FileStream(strDir + @"\FileSevice.dat", FileMode.Create);
                formatter.Serialize(fs, param._saveParam);//将一个对象图按字节的顺序持久化到一个指定的流
            }
            catch (Exception ex)
            {
                MessageBox.Show("保存参数失败!");
                return(false);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Close();
                }
            }
            return(true);
        }
Example #3
0
        void InitLog()
        {
            btnWCFClose.Enabled = false;
            _appParam           = AppValue.GetParam();
            AppParam.Load(ref _appParam);
            _appParam._saveDir = AppDomain.CurrentDomain.BaseDirectory + ConfigurationManager.AppSettings["TransferFilePath"];
            var dirPath = "上传地址:" + _appParam._saveDir;

            info.InitLogMsg("界面开启");
            info.InitLogMsg(dirPath);
        }