目前为止最简洁的C#文件夹Copy代码,不接受反驳

    xiaoxiao2022-06-28  140

    private static void CopyEntireDir(string sourcePath, string destPath) { foreach (string dirPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(dirPath.Replace(sourcePath, destPath)); } foreach (string newPath in Directory.GetFiles(sourcePath, "*.*", SearchOption.AllDirectories)) { File.Copy(newPath, newPath.Replace(sourcePath, destPath), true); } }

    如果您觉得我的文章对您有所帮助,欢迎扫码进行赞赏!

     


    最新回复(0)