ASP.NET C# Copy Directory with SubDirectories with System.IO
问题 I need to copy a whole directory C:\X to C:\Y\X, and I need the sub-folders to be copied as well. Is there any way to do it with the System.IO.File\Directory namespaces ? Thanks for all helpers! 回答1: This class will copy or move a folder, without recursive calls. The methods is using their own stacks to handle recursion, this is to avoid StackOverflowException . public static class CopyFolder { public static void CopyDirectory(string source, string target) { var stack = new Stack<Folders>();