471,305 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,305 software developers and data experts.

Notepad

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();
Jan 10 '06 #1
6 1978
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"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();

Jan 10 '06 #2
RSH


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

Jan 10 '06 #3
Hi,

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

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"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();

Jan 10 '06 #4
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,
"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();

Jan 10 '06 #5
On Tue, 10 Jan 2006 11:50:51 -0800, "cql90" <cq***@yahoo.com> wrote:
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

--

The ultimate truth is that there is no ultimate truth
Jan 10 '06 #6
Another helpful from Rossum, I am greatly appreciated. Take care and have a
good day...

"rossum" <ro******@coldmail.com> wrote in message
news:ij********************************@4ax.com...
On Tue, 10 Jan 2006 11:50:51 -08
00, "cql90" <cq***@yahoo.com> wrote:
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

--

The ultimate truth is that there is no ultimate truth

Jan 11 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by aa | last post: by
1 post views Thread by Roger | last post: by
4 posts views Thread by Jesper | last post: by
7 posts views Thread by kisshug | last post: by
9 posts views Thread by =?Utf-8?B?Vmlua2k=?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.