Questions tagged [console-application]

A console application is a computer program designed to be used via a text-only computer interface, such as a text terminal, the command line interface of some operating systems (Unix, DOS, etc.) or the text-based interface included with most Graphical User Interface (GUI) operating systems, such as the Win32 console in Microsoft Windows, the Terminal in Mac OS X, and xterm in Unix.

A console application is a computer program designed to be used via a text-only computer interface, such as a text terminal, the command line interface of some operating systems (Unix, DOS, etc.) or the text-based interface included with most Graphical User Interface (GUI) operating systems, such as the Win32 console in Microsoft Windows, the Terminal in Mac OS X, and xterm in Unix. A user typically interacts with a console application using only a keyboard and display screen, as opposed to GUI applications, which normally require the use of a mouse or other pointing device. Many console applications such as command line interpreters are command line tools, but numerous text-based user interface (TUI) programs also exist.

As the speed and ease-of-use of GUI applications have improved over time, the use of console applications has greatly diminished, but not disappeared. Some users simply prefer console based applications, while some organizations still rely on existing console applications to handle key data processing tasks.

7241 questions
1126
votes
30 answers

How can I get the application's path in a .NET console application?

How do I find the application's path in a console application? In Windows Forms, I can use Application.StartupPath to find the current path, but this doesn't seem to be available in a console application.
JSmyth
  • 11,993
  • 3
  • 23
  • 18
566
votes
19 answers

Can't specify the 'async' modifier on the 'Main' method of a console app

I am new to asynchronous programming with the async modifier. I am trying to figure out how to make sure that my Main method of a console application actually runs asynchronously. class Program { static void Main(string[] args) { …
danielovich
  • 9,217
  • 7
  • 26
  • 28
524
votes
31 answers

Could not load file or assembly ... An attempt was made to load a program with an incorrect format (System.BadImageFormatException)

I have two projects, ProjectA and ProjectB. ProjectB is a console application, which depends on ProjectA. Yesterday, everything was working fine, but suddenly today when I run ProjectB I get this: BadImageFormatException was unhandled: Could…
476
votes
31 answers

How do I launch the Android emulator from the command line?

I'm on Mac, working on Android development from the terminal. I have successfully created the HelloWorld project and now I'm trying to run it from the command line in the Android emulator. Which command runs the emulator for my HelloWorld…
Thierry Lam
  • 45,304
  • 42
  • 117
  • 144
440
votes
9 answers

How to stop C# console applications from closing automatically?

My console applications on Visual Studio are closing automatically once the program finishes the execution. I'd like to "pause" the applications at the end of their execution so that I can easily check the output. How can I achieve that?
Zignd
  • 6,896
  • 12
  • 40
  • 62
332
votes
4 answers

What is the command to exit a console application in C#?

What is the command in C# for exiting a console application?
Sababoni
  • 4,875
  • 4
  • 20
  • 21
312
votes
18 answers

Cooler ASCII Spinners?

In a console app, an ascii spinner can be used, like the GUI wait cursor, to indicate that work is being done. A common spinner cycles through these 4 characters: '|', '/', '-', '\' What are some other cyclical animation sequences to spice up a…
310
votes
11 answers

How can I use Ruby to colorize the text output to a terminal?

Using Ruby, how can I perform background and foreground text colorization for output in the terminal? I remember, when programming Pascal we all used to write our own textcolor(…) procedures to make our small educational programs look more pretty…
oldhomemovie
  • 14,621
  • 13
  • 64
  • 99
266
votes
9 answers

How to run .NET Core console application from the command line

I have a .NET Core console application and have run dotnet publish. However, I can't figure out how to run the application from the command line. Any hints?
devlife
  • 15,275
  • 27
  • 77
  • 131
264
votes
10 answers

Listen for key press in .NET console app

How can I continue to run my console application until a key press (like Esc is pressed?) I'm assuming its wrapped around a while loop. I don't like ReadKey as it blocks operation and asks for a key, rather than just continue and listen for the key…
karlstackoverflow
  • 3,298
  • 6
  • 30
  • 41
246
votes
10 answers

Show/Hide the console window of a C# console application

I googled around for information on how to hide one’s own console window. Amazingly, the only solutions I could find were hacky solutions that involved FindWindow() to find the console window by its title. I dug a bit deeper into the Windows API and…
Timwi
  • 65,159
  • 33
  • 165
  • 230
240
votes
18 answers

Password masking console application

I tried the following code... string pass = ""; Console.Write("Enter your password: "); ConsoleKeyInfo key; do { key = Console.ReadKey(true); // Backspace Should Not Work if (key.Key != ConsoleKey.Backspace) { pass +=…
Mohammad Nadeem
  • 9,134
  • 14
  • 56
  • 82
218
votes
5 answers

.NET Global exception handler in console application

Question: I want to define a global exception handler for unhandled exceptions in my console application. In asp.net, one can define one in global.asax, and in windows applications /services, one can define as below AppDomain currentDomain =…
Stefan Steiger
  • 78,642
  • 66
  • 377
  • 442
201
votes
12 answers

Can I write into the console in a unit test? If yes, why doesn't the console window open?

I have a test project in Visual Studio. I use Microsoft.VisualStudio.TestTools.UnitTesting. I add this line in one of my unit tests: Console.WriteLine("Some foo was very angry with boo"); Console.ReadLine(); When I run the test, the test passes,…
pencilCake
  • 51,323
  • 85
  • 226
  • 363
195
votes
5 answers

How to write Unicode characters to the console?

I was wondering if it was possible, in a console application, to write characters like ℃ using .NET. When I try to write this character, the console outputs a question mark.
Sam
  • 3,070
  • 3
  • 20
  • 26
1
2 3
99 100