首页 > Windows开发 > 详细

c#拷贝整个文件夹到指定文件夹下(非递归)

时间:2018-10-28 22:54:58      阅读:201      评论:0      收藏:0      [点我收藏+]
    public static void CopyEntireDir(string sourcePath, string destPath) {
       //Now Create all of the directories
        foreach (string dirPath in Directory.GetDirectories(sourcePath, "*",
           SearchOption.AllDirectories))
            Directory.CreateDirectory(dirPath.Replace(sourcePath, destPath));

       //Copy all the files & Replaces any files with the same name
        foreach (string newPath in Directory.GetFiles(sourcePath, "*.*",
           SearchOption.AllDirectories))
            File.Copy(newPath, newPath.Replace(sourcePath, destPath), true);
    }

 

c#拷贝整个文件夹到指定文件夹下(非递归)

原文:https://www.cnblogs.com/lee2011/p/9867750.html

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