public static void CopyDirectory(string sourcePath, string destinationPath, string filter = "", string unFilter = "") { DirectoryInfo directoryInfo = new DirectoryInfo(sourcePath); Directory.CreateDirectory(destinationPath); FileSystemInfo[] fileSystemInfos = directoryInfo.GetFileSystemInfos(); for (int i = 0; i < fileSystemInfos.Length; i++) { FileSystemInfo fileSystemInfo = fileSystemInfos[i]; string text = Path.Combine(destinationPath, fileSystemInfo.Name); if (fileSystemInfo is FileInfo) { if (!(unFilter != string.Empty) || !fileSystemInfo.FullName.EndsWith(unFilter)) { if (filter == string.Empty || fileSystemInfo.FullName.EndsWith(filter)) { File.Copy(fileSystemInfo.FullName, text, true); } } } else { Directory.CreateDirectory(text); Util.CopyDirectory(fileSystemInfo.FullName, text, string.Empty, string.Empty); } } }
public static void MoveDirectory(string sourcePath, string destinationPath) { Util.CopyDirectory(sourcePath, destinationPath, string.Empty, string.Empty); Util.DeleteFolder(sourcePath); }