Notepad

  • Thread starter Thread starter cql90
  • Start date Start date
C

cql90

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();
 
Hi,

What if you create a temp text file and pass it as a parameter?
You can use Path.GetTempfilename()
 
cql90,

What I would do is create a temporary file and then pass the path of
that file to the command line. Notepad should open it up and display the
contents.

Hope this helps.
 
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);

}

}
 
Wonderful help from all of you, I am deeply appreciated. The data which I
did collect in the runtime base on User's action, therefore I would like to
send it directly to the notepad, so I can save a lot of round trip.
Otherwise, I have to create a file, write data to the file and then pass the
file name to ProcessStartInfo. Any ways, you guys are awesome. Thanks you
is not a good word for me to say. Take care and have a nice day...

Kate,
 
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();

An alternative suggestion. Notepad is so simple it is reasonably easy
to create an equivalent text viewing form that you can load text into
from within your application, basically just a form with a menu bar
and a big multiline text box. There may even be something similar
lying around already.

rossum
 
Back
Top