반응형
public static void CopyDirectory(string sourceFolder, string destFolder)
{
    if (!Directory.Exists(destFolder))
        Directory.CreateDirectory(destFolder);
 
    string[] files = Directory.GetFiles(sourceFolder);
    string[] folders = Directory.GetDirectories(sourceFolder);
 
    foreach (string file in files)
    {
        string name = Path.GetFileName(file);
        string dest = Path.Combine(destFolder, name);
        File.Copy(file, dest);
    }
 
    foreach (string folder in folders)
    {
        string name = Path.GetFileName(folder);
        string dest = Path.Combine(destFolder, name);
        CopyDirectory(folder, dest);
    }
}
반응형

+ Recent posts