console-application

How to navigate a few folders up?

心不动则不痛 提交于 2019-11-27 06:31:15
One option would be to do System.IO.Directory.GetParent() a few times. Is there a more graceful way of travelling a few folders up from where the executing assembly resides? What I trying to do is to find a text file that resides one folder above the application folder. But the assembly itself is inside the bin, which is a few folders deep in the application folder. Other simple way is to do this: string path = @"C:\Folder1\Folder2\Folder3\Folder4"; string newPath = Path.GetFullPath(Path.Combine(path, @"..\..\")); Note This goes two levels up. The result would be: newPath = @"C:\Folder1

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

时光怂恿深爱的人放手 提交于 2019-11-27 06:11:29
问题 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: 回答1: It'll need doubles quotes, but will also likely need an @ to

How to fix “No overload for method ' ' takes 0 arguments”?

大城市里の小女人 提交于 2019-11-27 05:29:36
How can I fix this error? "No overload for method 'output' takes 0 arguments". The error is at the very bottom at "fresh.output();". I don't know what I'm doing wrong. Can someone tell me what I should do to fix the code? Here is my code: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication_program { public class Numbers { public double one, two, three, four; public virtual void output(double o, double tw, double th, double f) { one = o; two = tw; three = th; four = f; } } public class IntegerOne : Numbers { public override void

Is there a way to make a console application run using only a single file in .NET Core?

爷,独闯天下 提交于 2019-11-27 05:24:26
In .NET framework, you can make a single .EXE file that will run from the command line without having any extra config files (and if using ILMerge, you can put all .DLL references into the 1 .EXE assembly). I am taking a stab at using .NET Core to accomplish the same thing, but so far without success. Even the simplest Hello World application with no dependencies requires there to be a file named <MyApp>.runtimeconfig.json in order to run using dotnet.exe . dotnet F:\temp\MyApp.dll The contents of the <MyApp>.runtimeconfig.json are as follows: { "runtimeOptions": { "framework": { "name":

.NET Core console application, how to configure appSettings per environment?

橙三吉。 提交于 2019-11-27 05:24:03
问题 I have a .NET Core 1.0.0 console application and two environments. I need to be able to use appSettings.dev.json and appSettings.test.json based on environment variables I set at run time. This seems to be quite straight forward for ASP.NET Core web applications, via dependency injection and IHostingEnvironment and the EnvironmentName env. variable, however how should I wire things up for the console application (besides writing my own custom code that uses Microsoft.Framework.Configuration

C# console application icon

喜夏-厌秋 提交于 2019-11-27 05:23:57
Does anyone know how to set a C# console application's icon in the code (not using project properties in Visual Studio)? 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 itself in explorer. If you mean the icon of the application while it's running if you just double-click the file

How to handle key press events in c++

本秂侑毒 提交于 2019-11-27 05:12:48
I am writing a custom console program. And I want to make it look like an actual one. So I want to bind some actions with keypress events. For example when the up arrow is pressed previously executed commands should be shown to the user. I know about SDL. But I think that it's not a standard library, is it ?? If there is other alternative of it, that included in standard CPP library, please let me know. Thanks. You won't find anything in the standard library for that. It's all Platform-dependent. In Windows, you have functions like GetAsyncKeyState to get the state of a key on the keyboard for

How do I only allow number input into my C# Console Application?

元气小坏坏 提交于 2019-11-27 04:40:05
Console.WriteLine("Enter the cost of the item"); string input = Console.ReadLine(); double price = Convert.ToDouble(input); Hello, I want the keyboard buttons, A-Z, brackets, question mark, etc to be disabled. I want it so if you type it in, it will not show up in the Console. I only want the numbers 1-9 to show up. This is in C# Console application. Thanks for the help! try this code snippet string _val = ""; Console.Write("Enter your value: "); ConsoleKeyInfo key; do { key = Console.ReadKey(true); if (key.Key != ConsoleKey.Backspace) { double val = 0; bool _x = double.TryParse(key.KeyChar

What is the difference between getch() and getchar()?

China☆狼群 提交于 2019-11-27 04:15:30
What is the exact difference between the getch and getchar functions? getchar() is a standard function that gets a character from the stdin. getch() is non-standard. It gets a character from the keyboard (which may be different from stdin) and does not echo it. The Standard C function is is getchar() , declared in <stdio.h> . It has existed basically since the dawn of time. It reads one character from standard input ( stdin ), which is typically the user's keyboard, unless it has been redirected (for example via the shell input redirection character < , or a pipe). getch() and getche() are old

Command to close an application of console?

╄→гoц情女王★ 提交于 2019-11-27 03:48:05
I need to close the console when the user selects a menu option. I tried using close() but it did not work.. how can I do this? Priyank Environment.Exit and Application.Exit Environment.Exit(0) is cleaner. http://geekswithblogs.net/mtreadwell/archive/2004/06/06/6123.aspx Robert Northard By close, do you mean you want the current instance of the console app to close, or do you want the application process, to terminate? Missed that all important exit code: Environment.Exit(0); Or to close the current instance of the form: this.Close(); Useful link . namco You can Try This Application.Exit();