首页 > 其他 > 详细

文件复制

时间:2016-01-07 16:13:50      阅读:99      评论:0      收藏:0      [点我收藏+]
        #region 文件覆盖
        /// <summary>
        /// 文件覆盖
        /// </summary>
        /// <param name="destPath"></param>
        public void FileCopy(string destPath)
        {
            string path = "UploadFiles\\BaiYuApparelERPUpdate\\" + destPath;

            string filePath = ServerInfo.GetRootPath() + path;
            DirectoryInfo rootDirectory = new DirectoryInfo(filePath);

            ///////获取其所有子文件夹
            DirectoryInfo[] directories = rootDirectory.GetDirectories();
            foreach (DirectoryInfo temp in directories)
            {
                if (!Directory.Exists(ServerInfo.GetRootPath() + destPath + temp.Name))//检查文件夹是否存在,如果不存在则先创建文件夹
                {
                    temp.MoveTo(ServerInfo.GetRootPath() + destPath + temp.Name);
                }
                else
                {
                    FileCopy(destPath + temp.Name + "\\");
                }
            }
            ///////获取其所有子文件
            FileInfo[] files = rootDirectory.GetFiles();
            foreach (FileInfo temp in files)
            {
                temp.CopyTo(ServerInfo.GetRootPath() + destPath + temp.Name, true);
            }
        }
        #endregion

 

文件复制

原文:http://www.cnblogs.com/deep-blue/p/5109994.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!