private bool PerformTransform(string sourceFile, string transformFile, string destinationFile) { if (!File.Exists(sourceFile)) throw new FileNotFoundException("The source file was not found", sourceFile); var destinationDirectory = Path.GetDirectoryName(destinationFile); if (!Directory.Exists(destinationDirectory)) Directory.CreateDirectory(destinationDirectory); // If a transformation file does not exist, just copy sourceFile as the destinationFile if (!File.Exists(transformFile)) { var sourceContent = File.ReadAllText(sourceFile); File.WriteAllText(destinationFile, sourceContent); return false; } var transformTask = new TransformationTask(sourceFile, transformFile); transformTask.Execute(destinationFile); return true; }