console-application

Java: Updating text in the command-line without a new line

独自空忆成欢 提交于 2019-12-17 15:14:50
问题 I'd like to add a progress indicator to a command-line Java program. For example, if I'm using wget, it shows: 71% [===========================> ] 358,756,352 51.2M/s eta 3s Is it possible to have a progress indicator that updates without adding a new line to the bottom? Thanks. 回答1: First when you write, don't use writeln(). Use write(). Second, you can use a "\r" to Carriage Return without using \n which is a New line. The carriage return should put you back at the beginning of the line.

Must declare the table variable @table

守給你的承諾、 提交于 2019-12-17 12:20:49
问题 I'm a beginner in C# and SQL, i have this SQL insert statement that i want to perform. It asks for the table name among the other variables that i want to insert. But when i run this console app i get this error : Must declare the table variable @table This is a part of the code : StreamReader my_reader = getFile(args); string CS = formCS(); try { using (SqlConnection con = new SqlConnection(CS)) { SqlCommand com = new SqlCommand("insert into @table (time, date, pin) values (@time, @date,

How do I compile my App.config into my exe in a VS2010 C# console app?

雨燕双飞 提交于 2019-12-17 10:56:22
问题 I'm creating a console app in Visual Studio 2010 with c#. I want this app to be stand alone, in that all you need is the exe, and you can run it from anywhere. I also want to use app.config to store connection strings and so on. My problem is that I can't seem to figure out how to include that app.config data into the compiled exe. I do see it creates appname.exe.config, but I don't want people to have to worry about grabbing two separate files when they get the app. None of the googling I've

Redirect Console.Write… Methods to Visual Studio's Output Window While Debugging

旧街凉风 提交于 2019-12-17 10:53:13
问题 From a Console Application project in Visual Studio , I want to redirect Console 's output to the Output Window while debugging. 回答1: Change application type to Windows before debugging. Without Console window, Console.WriteLine works like Trace.WriteLine. Don't forget to reset application back to Console type after debugging. 回答2: class DebugWriter : TextWriter { public override void WriteLine(string value) { Debug.WriteLine(value); base.WriteLine(value); } public override void Write(string

Disabling input in C# Console until certain task is completed

时间秒杀一切 提交于 2019-12-17 10:02:32
问题 I'm working on a little part of my program, handling the input, basically I have this little code: bool Done = false; while (!Done) { ConsoleKeyInfo key = Console.ReadKey(true); if (key.Key == ConsoleKey.Enter) { //Action } } The main problem with this is that the code will handle the ReadKey even between actions. So if you have a menu where you can press keys and then it would say "you pressed: x" if you press any buttons while it shows you this message, the ReadKey already gets that new key

Compile to stand alone exe for C# app in Visual Studio 2010

ε祈祈猫儿з 提交于 2019-12-17 09:44:21
问题 Similar to this question Compile to a stand-alone executable (.exe) in Visual Studio But nothing there works for me. I've written an app that is very simple in C#. I want this to compile to a stand alone exe file, but I can't seem to find the proper settings to do this. Everything compiles into a publish folder and there is only the setup/install files. Thanks! 回答1: You just compile it. In the bin\Release (or bin\Debug) folder, the .exe will be in there. If you're asking how to make an

C# console application icon

感情迁移 提交于 2019-12-17 07:42:55
问题 Does anyone know how to set a C# console application's icon in the code (not using project properties in Visual Studio)? 回答1: You can't specify an executable's icon in code - it's part of the binary file itself. From the command line you'd use /win32icon:<file> if that's any help, but you can't specify it within the code of the application. Don't forget that most of the time the application's icon is displayed, your app isn't running at all! That's assuming you mean the icon for the file

Error-Attempt by method 'X.set_DbConnection(System.Data.Common.DbConnection)' to access method 'Y.get_Settings()' failed

一世执手 提交于 2019-12-17 07:33:24
问题 I created a console app and use EntityFramework 6.2 (for connection with MS SQL), MySql.Data 8.0.11 and MySql.Data.Entity 6.10.7 (for connection with MySQL). In this application I want to create a job like an SQL job but I don't want to use quertz.net. I have error: "Attempt by method 'MySql.Data.Entity.EFMySqlCommand.set_DbConnection(System.Data.Common.DbConnection)' to access method 'MySql.Data.MySqlClient.MySqlConnection.get_Settings()' failed." 回答1: MySql.Data.Entity 6.10.7 isn't

Make the console wait for a user input to close

大兔子大兔子 提交于 2019-12-17 07:15:52
问题 I have a console application that after performing its tasks, must give feedback to the user, such as "operation completed" or "operation failed" and the detailed error. The thing is, if I just "let it run", the output message will be printed but the console will close shortly afterwards, leaving no time to read the message. As far as I remember, in C++, every console application will end with a "press any key to exit" or something like that. In C# I can simulate this behavior with a Console

Strange behaviour of Console.ReadKey() with multithreading

耗尽温柔 提交于 2019-12-17 05:12:11
问题 I'm getting a weird problem when using Console.ReadKey() in a multithreaded program. My question is: Why is this happening? Is it a bug, or is it because I am abusing Console ? (Note that Console is supposed to be threadsafe, according to the documentation.) It's easiest to explain this with code: using System; using System.Threading; using System.Threading.Tasks; namespace ConsoleApplication2 { internal class Program { private static void Main(string[] args) { Console.WriteLine("X"); // Also