I want to exit the console window as soon as my files are written in folder at back end, but no matter whatever I try,
Environment.exit(0);
Environment.exit(1);
Environment.exit(-1);
Also since I am executing from the Main method, I am returning the value, but still my console window doesn't go off even after files are written to the destination folder.
Below is my code,
static void Main(string[] args)
{
string execute = "";
execute = data_info_pooling(args[0], args[1], args[2]);
Environment.Exit(0);
}
Also I tried for using Application.exit();
, but I am not able to get Application in drop-down box. I have explored almost all the possible helping links from Stack Overflow and searched for any help, but I have no idea where I am going wrong.
I am trying to run this console application by opening the command prompt and then executing the command as below
cd "Project Path\Debug"
"Project.exe" "First Parameter" " Second Parameter" "Third Parameter"`,
After files are written in the destination folder, the console window waits and after pressing Enter it just gives the path again to execute, but I want the window to exit as soon as the task of writing files is completed.
Second version of the code
I have deleted the for loop which is not necessary. Actually, I was wrong in application of my logic and apologize for my mistake. Some of the below comments helped me to realize my mistake. It's finally
Environment.exit();
Which works. Also I would like to give a try to another answer of forming batch.