console-application

Faster file move method other than File.Move

喜欢而已 提交于 2019-12-03 06:53:33
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(location, fileName), Path.Combine(rootDir, fileYear, fileMonth, fileName)); All of the other code runs pretty

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

家住魔仙堡 提交于 2019-12-03 06:38:25
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 There is nothing to mock in your scenario. Static Program.Main is a method just as any other and you test it as such -- by invoking it. The issue with static void method is that you can only verify whether

How to reserve a row for input in multi-threaded Console?

大憨熊 提交于 2019-12-03 06:25:17
This question has bugged me for a while now, and I realize it's hard to describe what I am looking for. I want to be able to reserve a row for text input in a C# Console Application, while still allowing other information to be updated in the remaining rows. More specifically, I'd like to make a small mud game where the game is updated even while the user is busy making input. It's important that the input doesn't block the information flow. I'd like to achieve the effect of the user writing input to the last visible row in the screen, while the other text append as usual, but not scrolling

Change icon for a Delphi console application

隐身守侯 提交于 2019-12-03 06:21:59
How do I change the program icon for a Delphi console application? The application settings is greyed in a console application. Bye. jpfollenius According to a July 2007 blog article by Nibu Thomas , there seems to be a SetConsoleIcon WinAPI function. Alternatively just put the icon in a resource file. Windows should use the first icon it encounters in the application's resources as the application icon. If the option to change the icon is disabled, then it is because you have deleted or neglected to add the following line from your DPR file: {$R *.res} Put it back, or add it if you never had

Is there a way to make a console window flash in the task bar programmatically

你说的曾经没有我的故事 提交于 2019-12-03 05:17:59
Basically I made console app that performs some task that takes a few minutes. I'd like to have it flash in the taskbar to let me know when it's done doing its thing. Daniel DiPaolo Using the answer that @Zack posted and another one to find the handle of a console app I came up with this and it works great. class Program { [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] static extern bool FlashWindowEx(ref FLASHWINFO pwfi); [StructLayout(LayoutKind.Sequential)] public struct FLASHWINFO { public UInt32 cbSize; public IntPtr hwnd; public UInt32 dwFlags; public UInt32 uCount;

How to run Console Application in Background (no UI)? [duplicate]

别来无恙 提交于 2019-12-03 04:41:53
Possible Duplicate: .Net Console Application that Doesn’t Bring up a Console I have a console application written in VB.NET that will become a scheduled task on a web server. It will run every ten minutes. The problem is that every ten minutes it displays the empty black CMD window while processing, which can be distracting. How can I configure it to run in the background (with no CMD window displayed)? Set on your Project in "Application" the Output Type to "Windows Application". 来源: https://stackoverflow.com/questions/2239151/how-to-run-console-application-in-background-no-ui

How can I get list of open tabs in Firefox via a command-line application?

£可爱£侵袭症+ 提交于 2019-12-03 03:53:09
问题 I have a lot of tabs open in Firefox. After I close Firefox and then run it again, the tabs are there. That's all right. However, from time to time, Firefox crashes and my tabs are lost. How do I get the open tabs and backup the list to some file? (With tabs in a file, I can also use Git, SVN, or whatever to store them and optionally find some link 'that I saw in my browser but can't remember what it was'.) What I got so far: I'm able to get some URLs, but that's doesn't seem to be exactly

AttachConsole(-1), but Console.WriteLine won't output to parent command prompt?

血红的双手。 提交于 2019-12-03 03:45:26
问题 If I have set my program to be a Windows Application , and used the AttachConsole(-1) API, how do I get Console.WriteLine to write to the console I launched the application from? It isn't working for me. In case it is relevant, I'm using Windows 7 x64, and I have UAC enabled. Elevating doesn't seem to solve the problem though, nor does using start /wait . Update Some additional background that might help: I've just discovered that if I go to the command prompt and type cmd /c MyProgram.exe ,

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

孤街醉人 提交于 2019-12-03 03:40:29
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 cases. Is there some other event which would be better in these other cases or which would be more

Startup.cs in a self-hosted .NET Core Console Application

喜欢而已 提交于 2019-12-03 02:14:49
问题 I have a self-hosted .NET Core Console Application . The web shows examples for ASP.NET Core but i do not have a webserver. Just a simple command line application. Is it possible to do something like this for console applications? public static void Main(string[] args) { // I don't want a WebHostBuilder. Just a command line var host = new WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); } I would