zoukankan      html  css  js  c++  java
  • 文件复制

            #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
  • 相关阅读:
    C++之类和对象
    PHP程序设计基础
    PHP函数和MySQL数据库
    HTML语言基础
    文件和目录1(文件属性和权限)
    文件IO
    查找
    使用tcpdump抓包实例
    导入模块的2种方法
    ansible启用sudo执行命令
  • 原文地址:https://www.cnblogs.com/deep-blue/p/5109994.html
Copyright © 2011-2022 走看看