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.

6415 questions
1023
votes
27 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
  • 10,945
  • 3
  • 21
  • 18
490
votes
16 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
  • 7,859
  • 7
  • 23
  • 28
447
votes
27 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…
408
votes
28 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
  • 41,912
  • 39
  • 108
  • 142
398
votes
9 answers

How to stop C# console applications from closing automatically?

My console applications on Visual Studio are closing automatically, so I'd like to use something like C's system("PAUSE") to "pause" the applications at the end of its execution, how can I achieve that?
Zignd
  • 6,246
  • 11
  • 34
  • 57
285
votes
4 answers

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

What is the command in C# for exit a Console Application?
Sababoni
  • 4,228
  • 4
  • 16
  • 18
282
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…
gmile
  • 13,077
  • 12
  • 59
  • 91
265
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…
242
votes
9 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,060
  • 5
  • 27
  • 41
237
votes
7 answers

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

I have a .NET Core console app and have run dotnet publish. However, I can't figure out how to run the application from the command line. Any hints?
devlife
  • 13,287
  • 23
  • 70
  • 126
219
votes
17 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
  • 8,364
  • 11
  • 51
  • 79
212
votes
8 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
  • 61,190
  • 29
  • 155
  • 224
207
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
  • 68,404
  • 63
  • 337
  • 408
168
votes
22 answers

Why is the console window closing immediately once displayed my output?

I'm studying C# by following the guides in MSDN. Now, I just tried the Example 1 (here is the link to MSDN), and I've encountered an issue: why is the console window closing immediately once displayed my output? using System; public class…
user962206
  • 13,699
  • 56
  • 164
  • 259
167
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
  • 45,443
  • 73
  • 211
  • 346
1
2 3
99 100