Created
April 1, 2014 09:59
-
-
Save nisar1/9911245 to your computer and use it in GitHub Desktop.
argment in console application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//argment in console application | |
//1. first you need to use third party dll or code | |
// NDesk.Options | |
//2. second you can use it as | |
using System; | |
using NDesk.Options; | |
namespace txtProcessorConsole | |
{ | |
class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
string smachine = ""; | |
string sip = ""; | |
int iport = 5005; | |
int ipass = 0; | |
string sxportPath = ""; | |
var p = new OptionSet() { | |
{ "m|machine=", "the name of the {machine} ", | |
(string v) => smachine = v }, | |
{ "i|ip=", "the address of the {ip} ", | |
(string v) => sip = v }, | |
{ "p|port=", "the address of the {ip} ", | |
(int v) => iport = v }, | |
{ "P|Pass=", "the address of the {ip} ", | |
(int v) => ipass = v }, | |
{ "e|export=", "the address of the {ip} ", | |
(string v) => sxportPath = v }, | |
}; | |
try | |
{ | |
p.Parse(args); | |
} | |
catch (OptionException e) | |
{ | |
Console.Write("greet: "); | |
Console.WriteLine(e.Message); | |
return; | |
} | |
Console.WriteLine(smachine + " " + sip + " " + iport + " " + ipass + " " + sxportPath); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment