简体   繁体   中英

Hold command prompt window in Visual Studio, when using Command Line Arguments

I need to test my console application with example input data, stored in a file. I want this file to be executed when I start my application in Visual Studio. In normal situation, in command prompt I write: program.exe < input.txt , the program is executed, I get the results and the screen (prompt) waits. I have found in Visual Studio that I can write this: "< input.txt" in Project->Properties->Debug->Command Line Arguments and when I hit F5 I can see that the program gives me the results, but the command window closes immediately. How can I hold this Window? I tried Ctrl+F5, but it doesn't load my input.txt file. Also the application is going to be send to another test system, so I should not write any Console.Read() (ReadLine, Readkey...) methods in the end of the file, because I think this will mess things up. I need answers for this problem for Visual Studio 2010 (2008, 2005) and languages: C/C++, C# if possible.

Just a quick hack if you can't work it out

if (System.Diagnostics.Debugger.IsAttached)
{
    Console.WriteLine("Press [ENTER] to finish");
    Console.Read();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM