public static void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target, Cancelable cancelable) { foreach (var dir in source.GetDirectories()) { CancelHelper.CheckThrowCancel(cancelable); CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name), cancelable); } foreach (var file in source.GetFiles()) { CancelHelper.CheckThrowCancel(cancelable); file.CopyTo(Path.Combine(target.FullName, file.Name)); } }
public static void Uninstall(Cancelable cancelable) { ExplorerContextMenuAdder.Unregister(); // -- var baseFolderPath = Installer.InstallationFolderPath; if (!Directory.Exists(baseFolderPath)) { return; } foreach (var directory in Directory.GetDirectories(baseFolderPath)) { CancelHelper.CheckThrowCancel(cancelable); Directory.Delete(directory, true); } foreach (var file in Directory.GetFiles(baseFolderPath)) { if (!string.Equals(Installer.InstallationExeFilePath, file, StringComparison.InvariantCultureIgnoreCase)) { CancelHelper.CheckThrowCancel(cancelable); File.Delete(file); } } // -- try { File.Delete(Installer.InstallationExeFilePath); } catch (Exception) { postPoneDeleteFile(Installer.InstallationExeFilePath); } try { Directory.Delete(Installer.InstallationFolderPath); } catch (Exception) { postPoneDeleteFile(Installer.InstallationFolderPath); } }
private static void deleteDirectoryContents(DirectoryInfo dir, Cancelable cancelable) { if (!dir.Exists) { return; } foreach (var directory in dir.GetDirectories()) { CancelHelper.CheckThrowCancel(cancelable); directory.Delete(true); } foreach (var file in dir.GetFiles()) { CancelHelper.CheckThrowCancel(cancelable); file.Delete(); } }