المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Read text from notepad in c#



C# Programming
11-06-2009, 07:02 AM
Hello,
I want to read and write in the notepad itself. I can write any text to notepad file but i can't able to read the text. Like if i have opened "sample.txt" file in notepad and i want to read the content of that file. Here is my sample code:

Process notePad = new Process();
notePad.StartInfo.FileName = "notepad.exe";
notePad.StartInfo.Arguments = "C:/Users/krinal/Desktop/1.txt";
notePad.StartInfo.UseShellExecute = false;
notePad.StartInfo.RedirectStandardOutput = true;
notePad.StartInfo.RedirectStandardInput = true;
notePad.Start();
notePad.WaitForInputIdle();
notepadhandle = notePad.MainWindowHandle;
//write text to notepad
SetForegroundWindow(notePad.MainWindowHandle);
SendKeys.SendWait("Testing");

using sendkeys() we can write to notepad, is there anything for reading?
Please help me out.
Thank you in advance.