I use this code to create an error string during processing and if it's
length is greater than 1 then I know it contains data and I write it to a
textfile. The user is then alerted and asked if they want to view the
errors. If they answer yes Notepad is spawned with the txt file that was
written a couple lines above it.
if (strError.Length > 1)
{
String strFilename = AppDomain.CurrentDomain.BaseDirectory +
"DataImportErrorLog-" + ".txt";
TextWriter tw = new StreamWriter(strFilename);
tw.WriteLine(strError);
tw.Close();
DialogResult result = MessageBox.Show("Errors occurred during the data
transfer. Would you like to view the Error Log now?", "Confirm",
MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
if (result == DialogResult.OK)
{
Process.Start("Notepad.exe", strFilename);
}
}
"cql90" <cq***@yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP14.phx.gbl...
Hi All,
I did use the block of code below to open a notepad, However, I would like
to insert some data which I did collect in the runtime into the notepad
before it show. How can I do it? Any help is greatly appreciated. Thanks
you very much in advance...
Kate
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo pcInfo = new
System.Diagnostics.ProcessStartInfo( "Notepad.exe" );
pcInfo.UseShellExecute = false;
pcInfo.RedirectStandardOutput = true;
myProcess.StartInfo = pcInfo;
myProcess.Start();
myProcess.WaitForExit();
myProcess.Close();