c# 备份数据

  #region 备份数据文件
        /// <summary>
        /// 备份数据文件
        /// </summary>
        /// <param name="strFileName">备份文件目录</param>
        /// <param name="strTypeKufen">发送还是接收</param>
        /// <param name="strMessageInfoType">消息类型</param>
        public void BackUpMessageInfo(String strFileName,String strTypeKufen,String strMessageInfoType)
        {
            if (File.Exists(strFileName))
            {
                string strPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "BackUpMessageInfo");
                string strCombinPath = DateTime.Today.ToString("yyyy-MM-dd").ToString()
                    + "\\" + strTypeKufen.Trim() + "\\" + strMessageInfoType.Trim();

                strPath = Path.Combine(strPath, strCombinPath);
                if (!Directory.Exists(strPath))
                {
                    Directory.CreateDirectory(strPath);
                }

                #region delele northeasttycoon
                //if (!Directory.Exists(strPath))
                //{
                //    Directory.CreateDirectory(strPath);
                //}
                //strPath = Path.Combine(strPath, DateTime.Today.ToString("yyyy-MM-dd"));
                //if (!Directory.Exists(strPath))
                //{
                //    Directory.CreateDirectory(strPath);
                //}

                //strPath = Path.Combine(strPath, strTypeKufen.Trim());
                //if (!Directory.Exists(strPath))
                //{
                //    Directory.CreateDirectory(strPath);
                //}
                //strPath = Path.Combine(strPath, strMessageInfoType.Trim());
                //if (!Directory.Exists(strPath))
                //{
                //    Directory.CreateDirectory(strPath);
                //}
                #endregion delete northeasttycoon

                string strTempFile = strFileName.Substring(strFileName.LastIndexOf("\\") + 1);
                strPath = Path.Combine(strPath, strTempFile);
                File.Copy(strFileName, strPath, true);
            }
        }
        #endregion 

 

posted @ 2016-07-25 15:15  东北大亨  阅读(528)  评论(0编辑  收藏  举报