console-application

Capturing an c# executable output from another C# program

核能气质少年 提交于 2019-11-29 15:24:31
I am executing a C# program i.e a .exe from another C# program. but the .exe has some Console.WriteLine() in its program. I want to get the standard output into my C# program. for example, Consider a C# executable i.e 1.exe and there is another Program 2.cs. I am calling from 2.cs 1.exe. Now there is some output that the console is displaying from 1. exe. But I want the ouput in my program 2.cs. for displaying information to user. Is it possible? Please help Thanks Sai sindhu You can use ProcessStartInfo.RedirectStandardOutput Property Process compiler = new Process(); compiler.StartInfo

calling an http url from a .net console application?

馋奶兔 提交于 2019-11-29 15:14:05
Is it possible to call an http url from a .net console application? can anyone give an idea.? public string DownloadUrl(string url) { return new System.Net.WebClient().DownloadString(url); } Maheep 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) Yes, its possible. Use the WebClient class. See a tutorial here http://www.dotnetperls.com/webclient 来源: https:/

getch returns 2 characters when I type one

岁酱吖の 提交于 2019-11-29 15:08:09
When I use getch, it always appends the caracter read with a null character. When I use the following code: #include "stdafx.h" #include <conio.h> int main() { char c = 0; while (c != 'x') { c = _getch(); printf("Char read: <%c> \n", c); } } It returns the follwing on the console, when I press the keys "asdx": Char read: <a> Char read: < > Char read: <s> Char read: < > Char read: <d> Char read: < > Char read: <x> This is compiled in VS 2017 in a plain new single file project, running on a windows 10 console window. I tried removing the _UNICODE and UNICODE define. Well, crap! It's a (rather

FileVersionInfo.GetVersionInfo() incorrect in Console Application

余生颓废 提交于 2019-11-29 15:07:50
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 same problem. However, if I built the test app as a Windows Application (it was a Console Application

How to call a console command in web application action in Yii?

筅森魡賤 提交于 2019-11-29 14:29:28
问题 I have a console command to do a consumer time, AND I need to know how to call (execute) it in a web application action in YII. class MyCommand extends CConsoleCommand{ public function actionIndex(){ $model = new Product(); $model->title = 'my product'; ... $model->save(); . . . } } I want to execute this code. 回答1: try this: Yii::import('application.commands.*'); $command = new MyCommand("test", "test"); $command->run(null); The 2 parameters with value "test" must be set but do not have an

C++ Change Output From “cout”

懵懂的女人 提交于 2019-11-29 14:21:23
Is it possible to change text printed with "cout"? I would like to make it show the current percentage of something without having to have a new line for each percentage. Is this possible? This works for me: std::cout << "1111"; std::cout << "\r"; std::cout << "2222"; \r is a carriage return symbol. Puts the "cursor" back to the beginning of the line. Alternatively you can use \b character. This is backspace. When printed it goes one character back. In general it is not possible. (imagine that the output from cout is fed directly to a printer. How would you instruct it to "unprint" the last

Prevent a console app from closing when not invoked from an existing terminal?

随声附和 提交于 2019-11-29 14:11:23
问题 There are many variants on this kind of question. However I am specifically after a way to prevent a console application in Python from closing when it is not invoked from a terminal (or other console, as it may be called on Windows). An example where this could occur is double clicking a .py file from the Windows explorer. Typically I use something like the following code snippet, but it has the unfortunate side effect of operating even if the application is invoked from an existing terminal

VSTS Online Building Setup Projects?

给你一囗甜甜゛ 提交于 2019-11-29 14:09:52
I have a .NET Console app with a setup project I am trying to port to VSTS Online (visualstudio.com) to make use of the source control and well as adding automated build/deploy. I've got the code uploaded just fine and it builds great, but am struggling with getting it to produce a MSI. I've tried introducing a command line task after the solution build to run devenv.com but I can't quite get that to work. Any thoughts on getting a setup project to build its MSI? Thanks! EDIT: Here's the command line task I tried: Tool: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv

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

半腔热情 提交于 2019-11-29 13:44:07
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! Bert Smith 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.DayOfWeek == Day ? fday : fday.AddDays(Day - fday.DayOfWeek); // CurDate = 2011.10.1 Occurance = 1, Day

How can I detect if “Press any key to continue . . .” will be displayed?

╄→尐↘猪︶ㄣ 提交于 2019-11-29 13:21:40
When running a console application in Visual Studio, depending on your settings, it will add a prompt after the program exits: Press any key to continue . . . I have found how to detect if I am running under the debugger(use Debugger.IsAttached ), but it isn't helpful. Press CTRL-F5 to Start Without Debugging sets this flag to false , yet still shows the prompt . I want to detect this because I'd like to display my own message and wait for a keypress, but not double up keypress checks . I don't want to muck with my general Visual Studio settings. If I can disable it for this project in a way