console-application

How to set default input value in .Net Console App?

你离开我真会死。 提交于 2019-11-28 13:22:03
How can you set a default input value in a .net console app? Here is some make-believe code: Console.Write("Enter weekly cost: "); string input = Console.ReadLine("135"); // 135 is the default. The user can change or press enter to accept decimal weeklyCost = decimal.Parse(input); Of course, I don't expect it to be this simple. I am betting on having to do some low-level, unmanaged stuff; I just don't know how. EDIT I know I can replace no input with the default. That's not what I am asking about. I am trying to LEARN what's involved in achieving the behavior I described: giving the user an

How to write to the console in a GUI application

岁酱吖の 提交于 2019-11-28 12:23:33
Background: We develop win32 applications, and use the "Thompson Toolkit" on windows to give us a unix-like shell that we use as our command-line. We have a GUI program (with a WinMain and message loop) that we want to write to the console, but printf and so on don't work, even when we launch the program from the console. How can we write to the console from a GUI program? We need to print text there so that an automated build system can display error messages and so on. Thanks. In short, you need to attach a console. For details and ready to use code, see http://www.codeproject.com/KB/dialog

how to handle spaces in file path if the folder contains the space?

烈酒焚心 提交于 2019-11-28 12:22:09
public static void launchProcess(string processName, string arguments, out string output) { Process p = new Process { StartInfo = { UseShellExecute = false, RedirectStandardOutput = true, FileName = processName, Arguments = arguments } }; p.Start(); output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); } And if my arguments contains the file names like: D:\Visual Studio Projects\ProjectOnTFS\ProjectOnTFS Then I get the error: It'll need doubles quotes, but will also likely need an @ to treat the string word-for-word ( verbatim string ) i.e. the "\" has a special meaning in string e.g. \t

How do I use command line arguments in my C# console app?

試著忘記壹切 提交于 2019-11-28 12:17:57
I am writing a url shortener app and I would like to also create a console app with C# to push the URLs to a WCF service which I have also created. WCF app will shorten the url on this URI; http://example.com/shorten/http://exaple.com so what I want is just that. My console exe file will be sitting inside c:\dev folder and on Windows command line, I would like to do this; c:\dev>myapp -throw http://example.com with this method I would like to talk to that service. there is no problem on talking part. But the problem is how can I supply this -throw thing on the command line and get a response

Re-Open WPF Window from a Console application

↘锁芯ラ 提交于 2019-11-28 12:04:36
I want to open a WPF Window from a Console application. After referring to this post , it works fine. The problem is: When the user closed the WPF Window (manually), it can no long be re-opened from the Console, throwing the exception message: "Cannot create more than one System.Windows.Application instance in the same AppDomain." Here is the code: class Program { static void Main(string[] args) { string input=null; while ((input = Console.ReadLine()) == "y") { //Works fine at the first iteration, //But failed at the second iteration. StartWpfThread(); } } private static void OpenWindow() { /

.Net Console Application that Doesn't Bring up a Console

自闭症网瘾萝莉.ら 提交于 2019-11-28 11:54:28
I have a console application I'm using to run scheduled jobs through windows scheduler. All the communication to/from the application is in email, event logging, database logs. Is there any way I can suppress the console window from coming up? Sure. Build it as a winforms app and never show your form. Just be careful, because then it's not really a console app anymore, and there are some environments where you won't be able to use it. Borrowed from MSDN ( link text ): using System.Runtime.InteropServices; ... [DllImport("user32.dll")] public static extern IntPtr FindWindow(string lpClassName

Ruby Keyboard event handling

不想你离开。 提交于 2019-11-28 11:26:43
问题 Hello im using curses to develop a small console application. I have a main loop section wich waits for user input, it uses the getstr function, of course this waits for the user to press enter. I would like to capture the up and down and tab keypresses. I suppose this can't be done with getstr. Anyone have any idea how to do this? EDIT: i've tried using STDIN.getc wich blocks the application from running, and getch doesnt catch the arrow keys EDIT #2 : im trying this code on windows. It

Python. How to print text to console as hyperlink?

旧巷老猫 提交于 2019-11-28 11:16:01
问题 I work with console application. My application uses urwid lib. In some cases I need to show very long hyperlinks into column of table as short text. I want to open link in browser onclick on text in column. So, my question is: It is possible to print message as hyperlink to console? Can you provide small example how to print text as hyperlink using python? 回答1: Yes, using some tools, like gNewt or Curses, you could create a button and 'on click' do an action (like open a browser to a given

How do I get a return value from Task.WaitAll() in a console app?

大憨熊 提交于 2019-11-28 10:40:23
I am using a console app as a proof of concept and new need to get an async return value. I figured out that I need to use Task.WaitAll() in my main method to avoid needing an async "main()" method, which is illegal. I'm now stuck trying to figure out an overload that allows me to use generics or just returns an object that I can cast, but while in Main(). You don't get a return value from Task.WaitAll . You only use it to wait for completion of multiple tasks and then get the return value from the tasks themselves. var task1 = GetAsync(1); var task2 = GetAsync(2); Task.WaitAll(task1, task2);