console-application

Using AttachConsole, while the process I've attached with is running and spewing, I can still type and run other commands

心已入冬 提交于 2019-12-04 10:54:50
问题 Using AttachConsole, while the process I've attached with is running and spewing, I can still type and run other commands. My program runs in either a form, or from command line. If started with arguments it runs in the command window. I use AttachConsole(-1) to attach my process to command window I called from. It works great, I get all my output spew from my process. However, the console still processes user input from the keyboard, whatever I type, for instance, if I type 'cls' and hit

Dependency Injection and project structure for Console applications

被刻印的时光 ゝ 提交于 2019-12-04 10:53:09
问题 I have 4 projects: Core (IServer): System System.Core DependencyResolver: Core StructureMap Infrastructure (Service): Core External dependency Console: Core DependencyResolver Requierements: I am trying to use StructureMap only in the DependencyResolver. Furthermore the Console application should not know anything about Infrastucture. When I do not want to reference StructureMap on my Console Application I have to build a ServiceLocator. In the DependencyResolver I have a Bootstrapper that is

Faster file move method other than File.Move

纵饮孤独 提交于 2019-12-04 10:52:32
问题 I have a console application that is going to take about 625 days to complete. Unless there is a way to make it faster. First off I am working in a directory that has around 4,000,000 files in if not more. I'm working in a database that has a row for each file and then some. Now working with the SQL is relatively fast, the bottleneck is when I use File.Move() each move takes 18 seconds to complete. Is there a faster way than File.Move() ? This is the bottleneck: File.Move(Path.Combine

Console Application - Unable to find a version of the runtime to run this application (and I have them all)

风流意气都作罢 提交于 2019-12-04 10:43:59
Like others, I'm having an issue with a simple console application that reads records from our database. This small program needs to sit on our file server. It reads new records and forwards a summary off to the parent company. This is going to be a scheduled task that runs every X minutes. I do NOT want an Installer, because I don't want the server to require a reboot. From the screenshot, notice I have almost all versions of the framework already installed and that the debug information is copied into the program folder. This is the debug version of the program, but no other debug

C# Unit Testing(Nunit) the Main method of a console app?

◇◆丶佛笑我妖孽 提交于 2019-12-04 10:42:05
问题 I have a question on unit testing the Main method of a console app. The standard signature is public static void Main(string[] args) I want to be able to test to ensure that only 1 parameter is passed in. If more than one parameter is passed in that i want the test to fail. I don't think i can mock this with MOQ as its a static method. Anyone have any experience with this? Any ideas ? Thanks 回答1: There is nothing to mock in your scenario. Static Program.Main is a method just as any other and

How to call REST API from a console application?

对着背影说爱祢 提交于 2019-12-04 10:39:57
How to call REST API from a console application? The response from my REST service will be XML format. In web I am calling like this string url = string.Format("{0}/name?PrimaryName={1}", ConfigurationManager.AppSettings["URLREST"], txtName.Text); string details= CallRestMethod(url); public string CallRestMethod(string url) { HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(url); webrequest.Method = "GET"; webrequest.ContentType = "application/x-www-form-urlencoded"; webrequest.Headers.Add("Username", "xyz"); webrequest.Headers.Add("Password", "abc"); HttpWebResponse webresponse =

Does Application.ApplicationExit event work to be notified of exit in non-Winforms apps?

烂漫一生 提交于 2019-12-04 09:41:13
问题 Our code library needs to be notified when the application is exiting. So we have subscribed to the System.Window.Forms.Application.ApplicationExit event. This works nicely for Winforms apps, but does it also work for other types of applications such as console apps, services, and web apps (such as ASP.NET)? The namespace would suggest that it doesn't, and it presumably gets raised when Application.Exit() is called (explicitly or implictly), which may not be correct to call for these other

How to get system currency symbol to a string

ぐ巨炮叔叔 提交于 2019-12-04 09:16:32
If I do this: Console.Write("The sum is {0:c}", 12); I'm on a Swedish computer so it'll return: The sum is 12,00 kr But is there a simple way of getting just the currency symbol, without a number? Like this (obviously this doesn't work, but just to show what I'm after): Console.Write("The symbol is {c}"); I would like that to output: The symbol is kr This code should return the currency symbol you're looking for. System.Globalization.RegionInfo.CurrentRegion.CurrencySymbol You could also use the following instead to get the ISO currency symbol System.Globalization.RegionInfo.CurrentRegion

Dijkstra's Algorithm Issue

谁都会走 提交于 2019-12-04 08:38:38
I'm working on a program where I have to find the shortest path between 12 cities, starting in Seattle and ending in Miami. I'm using Dijkstra's Algorithm because the paths are weighted. Here is my code so far, it all works except the answer I get is not the one I need, although it is correct. This part of the code sets everything up as well as creates the sorting algorithm. class Graph { Dictionary<string, Dictionary<string, int>> vertices = new Dictionary<string, Dictionary<string, int>>(); public void add_vertex(string name, Dictionary<string, int> edges) { vertices[name] = edges; } public

How do I make my java application open a console/terminal window?

青春壹個敷衍的年華 提交于 2019-12-04 08:31:55
问题 Is there any way I can make an executable .jar that will open up the command line when double clicked? I'm making a text-based adventure game. As of right now it is just a maze with rooms. Eventually it is going to be much bigger and more in depth but for now I just want to get the basic structure down. Anyways, to make this work I've been getting output and input from the System.out.printf command and the java.util.Scanner. It's all working beautifully so far but I've realized I'm going to