【文件属性】:
文件名称:C#getopt(命令行处理函数)
文件大小:7KB
文件格式:ZIP
更新时间:2016-08-27 09:04:04
C# getopt cmd dll
转自:http://www.codeproject.com/Articles/26502/GetOpt-for-NET
C#中的getopt封装,方便处理cmd命令。添加引用后,使用范例如下:
using CodePoints;
using System;
...
public static void Main ( string [] args ) {
int c = 0, aflag = 0, bflag = 0;
string cvalue = "(null)";
while ( ( c = GetOpt.GetOptions(args, "abc:") ) != ( -1 ) ) {
switch ( ( char ) c ) {
case 'a':
aflag = 1;
break;
case 'b':
bflag = 1;
break;
case 'c':
cvalue = GetOpt.Text;
break;
case '?':
Console.WriteLine("Error in parsing option '{0}'", GetOpt.Item);
break;
default:
return;
}
}
Console.WriteLine("aflag = {0}, bflag = {1}, cvalue = {2}", aflag, bflag, cvalue);
for ( int n = GetOpt.Index ; n < args.Length ; n++ )
网友评论
- 可以使用,但是7-zip解压不了,还得下载指定的快压解压软件
- 代码还可以。