CSharp examples for System.IO:File Copy
Copy All files in a folder
using System.IO;/*w ww. ja va 2s . c om*/ using System.Text; using System.Linq; using System.Collections.Generic; using System; public class Main{ public static void CopyAll(string source, string target) { EnsureDirectoryExists(target); foreach (var file in new DirectoryInfo(source).GetFiles()) { file.CopyTo(Path.Combine(target, file.Name), true); } foreach (DirectoryInfo sourceSubdirectory in new DirectoryInfo(source).GetDirectories()) { DirectoryInfo targetSubdirectory = Directory.CreateDirectory(Path.Combine(target, sourceSubdirectory.Name)); CopyAll(sourceSubdirectory.FullName, targetSubdirectory.FullName); } } }