console-application

c# loop until Console.ReadLine = 'y' or 'n'

我与影子孤独终老i 提交于 2019-12-02 18:46:19
问题 I'm fairly new to c#, and writing a simple console app as practice. I want the application to ask a question, and only progress to the next piece of code when the user input equals 'y' or 'n'. Here's what I have so far. static void Main(string[] args) { string userInput; do { Console.WriteLine("Type something: "); userInput = Console.ReadLine(); } while (string.IsNullOrEmpty(userInput)); Console.WriteLine("You typed " + userInput); Console.ReadLine(); string wantCount; do { Console.WriteLine(

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

﹥>﹥吖頭↗ 提交于 2019-12-02 18:45:26
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 what I see in Firefox: $c = ((gc c:\Users\..\AppData\Roaming\Mozilla\Firefox\Profiles\xfvj8vd5.default

Batch script: save stdout and have the output in the console too

杀马特。学长 韩版系。学妹 提交于 2019-12-02 18:28:20
问题 By default the output of commandline applications is presented in console window and I know that using > or >> we can re-wrire/append the stdout to an external file but what if the commandline application doesn't have internal logging facility to save the output. I want the stdout to be both in the console and be saved in an external file. Is such a thing possible? 回答1: Try something like this: @echo off echo hello > log.txt & type log.txt pause But using this you can only have one command

Project Unavailable in Visual Studio 2010 Solution

无人久伴 提交于 2019-12-02 18:19:10
问题 I created the tool below to create a VS2010 Solution using existing project folders from our non-Microsoft version control. When the code runs, you tell it what folder your code is in, what folder your solution needs to go to, then accept the solution name to create in the folder you pick. It was working OK for a while, until I made some changes to allow for multiple Projects within the same Solution, but now it is broken. No error messages are thrown, so I am having difficulty isolating what

How can I use System.Web.Caching.Cache in a Console application?

老子叫甜甜 提交于 2019-12-02 17:59:56
Context: .Net 3.5, C# I'd like to have caching mechanism in my Console application. Instead of re-inventing the wheel, I'd like to use System.Web.Caching.Cache (and that's a final decision, I can't use other caching framework, don't ask why). However, it looks like System.Web.Caching.Cache is supposed to run only in a valid HTTP context. My very simple snippet looks like this: using System; using System.Web.Caching; using System.Web; Cache c = new Cache(); try { c.Insert("a", 123); } catch (Exception ex) { Console.WriteLine("cannot insert to cache, exception:"); Console.WriteLine(ex); } and

Implement a C# Client that uses WebServices over SSL?

折月煮酒 提交于 2019-12-02 17:42:02
So I've got a ServiceReference added to a C# Console Application which calls a Web Service that is exposed from Oracle. I've got everything setup and it works like peaches when it's not using SSL (http). I'm trying to set it up using SSL now, and I'm running into issues with adding it to the Service References (or even Web References). For example, the URL (https) that the service is being exposed on, isn't returning the appropriate web methods when I try to add it into Visual Studio. The underlying connection was closed: An unexpected error occurred on a send. Received an unexpected EOF or 0

How to create ASCII animation in Windows Console application using C#?

这一生的挚爱 提交于 2019-12-02 17:33:10
I would like it to display non-flickery animation like this awesome Linux command; sl http://www.youtube.com/watch?v=9GyMZKWjcYU I would appreciate a small & stupid example of say ... a fly. Thanks! Just use Console.SetCursorPosition for moving the cursor to a certain position, then Console.Write a character. Before each frame you have to delete the previous one by overwriting it with spaces. Heres a little example I just built: class Program { static void Main(string[] args) { char[] chars = new char[] { '.', '-', '+', '^', '°', '*' }; for (int i = 0; ; i++) { if (i != 0) { // Delete the

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

风流意气都作罢 提交于 2019-12-02 17:12:22
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 , Then console output works . The same is true if I launch a command prompt, open a cmd.exe sub-process,

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

二次信任 提交于 2019-12-02 14:14:32
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 like to use a Startup.cs like in ASP.NET Core but on console. How to this? All .NET Core applications

Issue using switch case statement [closed]

南楼画角 提交于 2019-12-02 13:45:48
My code is as follows. Basically, I am reading an excel file and storing its contents into an object array. Then, I use a switch case statement to do different operations. Check my code below:- using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data; using System.Drawing; using System.ComponentModel; using Excel = Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Excel; namespace Excel1 { class Program { public static void Main(string[] args) //public void ExcelOps() { //string str; Excel.Application xlApp