public void MergeFile() { try { var fileName = ActiveFileName; var cp = new CodeProcessing.CodeProcessor(); cp.ShowMergeComments = true; cp.ProcessFile(fileName); string tempFileName = string.Empty; using (var tempFileOutput = new TempFileOutput(string.Concat(Path.GetFileNameWithoutExtension(fileName), "_merge"), Path.GetExtension(fileName))) { var errors = cp.Errors; if (errors.Any()) { tempFileOutput.WriteLine("// Errors encountered during processing:"); foreach (var error in errors) { if (error.Line != null && error.Line.File != null) tempFileOutput.WriteLine(string.Format("// {0}({1}): {2}", error.Line.FileName, error.Line.LineNum, error.Message)); else tempFileOutput.WriteLine(error.Message); } tempFileOutput.WriteLine(string.Empty); } foreach (var line in cp.Lines) { tempFileOutput.WriteLine(line.Text); } tempFileName = tempFileOutput.FileName; } OpenFile(tempFileName); } catch (Exception ex) { Errors.Show(NppWindow, ex); } }
public void FecFile() { try { string baseFileName = ProbeEnvironment.FindBaseFile(ActiveFileName); if (string.IsNullOrEmpty(baseFileName)) { MessageBox.Show("Base file could not be found."); return; } string fileName; using (TempFileOutput output = new TempFileOutput( Path.GetFileNameWithoutExtension(baseFileName) + "_fec", Path.GetExtension(baseFileName))) { ProcessRunner pr = new ProcessRunner(); int exitCode = pr.CaptureProcess("fec.exe", "/p \"" + baseFileName + "\"", Path.GetDirectoryName(baseFileName), output); if (exitCode != 0) { Errors.Show(NppWindow, "FEC returned exit code {0}.", exitCode); return; } fileName = output.FileName; } OpenFile(fileName); } catch (Exception ex) { Errors.Show(NppWindow, ex); } }