I have program called gen.exe
, which prints 1 to ..... It just keeps prints and saves them in file.
Now, in my .net application I'm using the following code to create a process and to run the program :
process = new Process
{
StartInfo =
{
FileName = "gen"//defined in filepath or in the same directory
}
};
process.Start();
Now I want to terminate this process. But when I use kill, it closes the console and some numbers printed at very last doesn't appear on the file and sometimes it says file is corrupted.
All I want is a simple cancellation of the process, just like pressing CTRL + C
.
How can I achieve this ?
I have tried Dispose, Close, Kill.