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

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);
            }
        }

 

你可能感兴趣的:(目前为止最简洁的C#文件夹Copy代码,不接受反驳)