/// <summary> /// Converts all webforms aspx pages and their corresponding cs pages in a directory. Subdirectories are NOT processed. /// </summary> /// <param name="path">Path.</param> public void ConvertProjectInDirectory(string path) { foreach (var file in Directory.GetFiles(path, "*.aspx")) { var outputFile = WebFormsExtension.Replace(file, RazorExtension); Markup.ConvertToRazor(file, outputFile); ConvertedFiles.Add(file); } foreach (var file in Directory.GetFiles(path, "*.aspx.cs")) { var outputFile = WebFormsExtension.Replace(file, RazorExtension + ".cs"); CodeBehind.ConvertToCSharpCodeBehind(file, outputFile); ConvertedFiles.Add(file); } }
/// <summary> /// Process a single webforms aspx page and its .cs pair /// </summary> /// <param name="path">the full file path to the aspx page</param> public void ConvertFile(string path) { var match = WebFormsExtension.Match(path); if (match.Success) { Markup.ConvertToRazor(path, WebFormsExtension.Replace(path, RazorExtension)); ConvertedFiles.Add(path); CodeBehind.ConvertToCSharpCodeBehind(path, WebFormsExtension.Replace(path, RazorExtension + ".cs")); ConvertedFiles.Add(path); } else { throw new ArgumentException($"{path} file isn't a WebForms view page"); } }