public void compilefile(ref System.Windows.Controls.RichTextBox rtb,ref TabItem tabitem) { var range = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd); FileInfo filetocompile = new FileInfo(Path.GetTempPath() + tabitem.Header.ToString()); using (FileStream fs = filetocompile.Open(FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) { range.Save(fs, System.Windows.DataFormats.Text); fs.Close(); } try{ pf = new ProcessStartInfo(@"E:\com.bat"); pf.FileName = @"E:\com.bat"; pf.Arguments = string.Format("{0} {1} {2} {3} {4}", "\"C:\\Program Files (x86)\\Java\\jdk1.7.0_13\\bin\\\"", "javac", tabitem.Header.ToString(), "java", tabitem.Header.ToString().Substring(0, tabitem.Header.ToString().LastIndexOf('.'))); pf.CreateNoWindow = true; pf.ErrorDialog = false; pf.UseShellExecute = false; pf.RedirectStandardInput = true; pf.RedirectStandardOutput = true; pf.RedirectStandardError = true; pf.WorkingDirectory = Path.GetTempPath(); p = new Process(); p.StartInfo = pf; p.Start(); input = p.StandardInput; string inputstring = ""; input.AutoFlush = true; do { if (p.StandardError.ReadToEnd() != "") { consoleTextBlock.IsDocumentEnabled = false; consoleTextBlock.AppendText(p.StandardOutput.ReadToEnd()); consoleTextBlock.AppendText(p.StandardError.ReadToEnd()); } else { consoleTextBlock.AppendText(p.StandardOutput.ReadToEnd()); consoleTextBlock.AppendText(p.StandardError.ReadToEnd()); } consoleTextInput.Focus(); consoleTextBlock.ScrollToEnd(); consoleTextBlock.IsReadOnly = true; System.Windows.MessageBox.Show(p.ExitCode.ToString()); } while (p.HasExited != true); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.ToString()); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)