private void ReplaceParamsInFilePath(Dictionary <string, string> genParameters) { var parameterReplacements = new FileRenameParameterReplacements(genParameters); var path = GenContext.Current.OutputPath; var filesToMove = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories) .ToList() .Where(file => parameterReplacements.FileRenameParams.Any(param => file.Contains(param.Key))); if (filesToMove != null && filesToMove.Count() > 0) { foreach (var f in filesToMove) { var file = new FileInfo(f); var newPath = parameterReplacements.ReplaceInPath(f); Fs.EnsureFolder(Directory.GetParent(newPath).FullName); file.MoveTo(newPath); } } var directoriesToDelete = Directory.EnumerateDirectories(path, "*", SearchOption.AllDirectories) .ToList() .Where(file => parameterReplacements.FileRenameParams.Any(param => file.Contains(param.Key))); if (directoriesToDelete != null && directoriesToDelete.Count() > 0) { foreach (var directory in directoriesToDelete) { Fs.SafeDeleteDirectory(directory, false); } } }
public static string GetOutputPath(this ICreationPath cp, Dictionary <string, string> parameters) { var parameterReplacements = new FileRenameParameterReplacements(parameters); var newPath = parameterReplacements.ReplaceInPath(cp.Path); return(newPath); }