Hi everyone...
Im starting c sharp scripting today and i wanted to write a script using which i can open the notepad application and write a string into it...
This is my code...
using System;
using System.IO;
using System.Diagnostics;
using System.ComponentModel;
namespace Process_StandardInput_Sample
{
class StandardInputTest
{
static void Main()
{
Process myProcess = new Process();
myProcess.StartInfo.FileName = "notepad.exe";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.Start();
StreamWriter myStreamWriter = myProcess.StandardInput;
String inputText;
inputText = "hithere\n";
Console.WriteLine(inputText);
myStreamWriter.WriteLine(inputText);
myStreamWriter.Close();
myProcess.WaitForExit();
myProcess.Close();
}
}
}
Once i run the script, all i get is a notepad window and the string "hithere" is not present...what mistake am i doing here..
advance thanks for the help
DG