console-application

Run console application (.exe) from within ASP.NET application (IIS 7,5)

天涯浪子 提交于 2019-11-28 09:51:53
问题 I have an ASP.NET application on Windows 2008 R2 (.NET Framework 4.0, IIS 7.5) and I want to run a console application when I click a button on a web page. Here is the code: protected void btnUpdate_Click(object sender, EventArgs e) { string fileLocation = @"D:\DTDocs\App_Code\LoadDTDocsXML.exe"; ProcessStartInfo oStartInfo = new ProcessStartInfo(); oStartInfo.FileName = fileLocation; oStartInfo.UseShellExecute = false; Process.Start(oStartInfo); } When I run ASP.NET application from within

C#: Is it possible to have a single application behave as Console or Windows application depending on switches?

家住魔仙堡 提交于 2019-11-28 09:23:02
I have a simple application that I would like to sort of automate via switches. But when I do run it via switches I don't really want a user interface showing. I just want it to run, do it's job, print stuff out in the console, and exit. On the other hand if I don't run it with any switches I want the user interface to pop up. And in this case I don't really want a console window hanging around in the background. Is there any way I can do this, or do I have to create two separate projects, one Console Application and one Windows Application? Whilst not exactly what you have asked, I've

FileVersionInfo.GetVersionInfo() incorrect in Console Application

老子叫甜甜 提交于 2019-11-28 08:53:31
问题 I'm getting some serious weirdness using FileVersionInfo.GetVersionInfo() and was hoping somebody might be able to help. The basics of the issue is that I am iterating through all the files in a folder calling GetVersionInfo() on each. There are about 300 files. This works ok for all but 2 of the files. For these DLLs I am getting comepletely incorrect info back from GetVersionInfo(). In order to eliminate all other variables, I extracted this call into a simple test app and it still got the

Reading the RGB values of the console color palette

烂漫一生 提交于 2019-11-28 08:41:15
问题 Meat In C or C++ is there any way to read the color palette RGB values directly? Especially interesting is the extended color space used by xterm (and others) to define up to 256 terminal colors. Potatoes The case in point is that I want to define my own colors (using ANSI escape sequences, like \e]4;3;rgb:cc/78/33\e\\ , or directly in c) but I need to save the users colors before I redefine them (in the unlikely event that they have already redefined their colors) so that I can restore them

Handle CTRL+C on Win32

雨燕双飞 提交于 2019-11-28 08:34:14
I have some problems with the handling of CTRL + C events, in a Win32 C++ console program. Basically my program looks like this: (based on this other question: Windows Ctrl-C - Cleaning up local stack objects in command line app ) bool running; int main() { running = true; SetConsoleCtrlHandler((PHANDLER_ROUTINE) consoleHandler, TRUE); while (running) { // do work ... } // do cleanup ... return 0; } bool consoleHandler(int signal) { if (signal == CTRL_C_EVENT) { running = false; } return true; } The problem is the cleanup code not being executed at all. After the execution of the handler

calling an http url from a .net console application?

偶尔善良 提交于 2019-11-28 08:29:26
问题 Is it possible to call an http url from a .net console application? can anyone give an idea.? 回答1: public string DownloadUrl(string url) { return new System.Net.WebClient().DownloadString(url); } 回答2: Here is a nice example if you are trying to fetch HTML from a web page using HTTP. UPDATE: As you have posted in comment that only thing you expect in response is a string would be good to use WebClient as Chris Fulstow says in his answer. System.Net.WebClient().DownloadString(url) 回答3: Yes, its

how to execute console application from windows form?

萝らか妹 提交于 2019-11-28 08:27:37
I want to run a console application (eg app.exe) from a windows form load event. I'v tried System.Diagnostics.Process.Start(), But after it opens app.exe, it closes it immidiately. Is there any way that I can run app.exe and leave it open? If you are just wanting the console window to stay open, you could run it with something like this command: System.Diagnostics.Process.Start( @"cmd.exe", @"/k c:\path\my.exe" ); Try doing this: string cmdexePath = @"C:\Windows\System32\cmd.exe"; //notice the quotes around the below string... string myApplication = "\"C:\\Windows\\System32\\ftp.exe\""; //the

Console window still popping up even after ProcessWindowStyle.Hidden;

爷,独闯天下 提交于 2019-11-28 08:01:31
问题 I have to run a console application from my Windows Application. The console application I want to run is an Embedded Resource in my application, and I am calling it like this: // Run the updater and grab its output Process Updater = new Process(); Updater.StartInfo.FileName = "C:\\tmp\\tmp.exe"; Updater.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; Updater.StartInfo.UseShellExecute = false; Updater.StartInfo.RedirectStandardOutput = true; Updater.Start(); string UpdaterOutput = Updater

How to calculate 2nd Friday of Month in C# [duplicate]

喜夏-厌秋 提交于 2019-11-28 07:30:45
问题 Possible Duplicate: How to find the 3rd Friday in a month with C#? Hi everyone, I've wrote a little console utility that spits out a line into a text file. I want this line to include the second Friday of the current month. Is there any way to do this? Thanks everyone! 回答1: Slight variation on @druttka: using an extension method. public static DateTime NthOf(this DateTime CurDate, int Occurrence , DayOfWeek Day) { var fday = new DateTime(CurDate.Year, CurDate.Month, 1); var fOc = fday

Redirect console to Visual Studio debug output window in app.config

戏子无情 提交于 2019-11-28 07:12:21
问题 I want to get my Console.WriteLine() commands to appear in my "Output" window with my Debug.WriteLine() statements. I think I figured out how to do this once, but I can't remember / find on google how to do it again. I seem to remember being able to do this in the app.config file. I find plenty of instructions on how to get console and debug statements to appear in the output of the Console, but not how to get them to appear in the "Output" window. Is it possible? 回答1: Basically the most