zoukankan      html  css  js  c++  java
  • C#拷贝整个文件夹以及子目录和其中文件

       private void CopyDirectory(string srcPath, string desPath)

            {
                string folderName = srcdir.Substring(srcdir.LastIndexOf("\")+1);
     
                string desfolderdir = desPath +"\"+ folderName;
     
                if (desdir.LastIndexOf("\") == (desPath.Length - 1))
                {
                    desfolderdir = desPath + folderName;
                }
                string[] filenames = Directory.GetFileSystemEntries(srcPath);
     
                foreach (string file in filenames)
                {
                    if (Directory.Exists(file))
                    {
     
                        string currentdir = desfolderdir + "\" + file.Substring(file.LastIndexOf("\") + 1);
                        if (!Directory.Exists(currentdir))
                        {
                            Directory.CreateDirectory(currentdir);
                        }
     
                        CopyDirectory(file, desfolderdir);
                    }
     
                    else 
                    {
                        string srcfileName = file.Substring(file.LastIndexOf("\")+1);
     
                        srcfileName = desfolderdir + "\" + srcfileName;
     
     
                        if (!Directory.Exists(desfolderdir))
                        {
                            Directory.CreateDirectory(desfolderdir);
                        }
                         
                         
                        File.Copy(file, srcfileName);
                    }
                }
           }
  • 相关阅读:
    Camera2Raw
    ActiveNotifications
    百度检索技巧
    Android开发ScrollView上下左右滑动事件冲突整理一(根据事件)
    四种方案解决ScrollView嵌套ListView问题
    10 条提升 Android 性能的建议
    Android操作外置SD卡和U盘相关文章
    SQLServer通过链接服务器调用Oracle 存储过程
    Easy Image X2 快速分区-恢复镜像-万能驱动 一站式操作!
    纯净PE推荐——优启通 v3.3.2019.0605
  • 原文地址:https://www.cnblogs.com/LCLBook/p/10997206.html
Copyright © 2011-2022 走看看