广东话运行的应用程序(C#)通过CMD
我无法通过CMD执行我的应用程序,当应用程序试图读取它发送给它(文本文件),它失败的说法...广东话运行的应用程序(C#)通过CMD
当我试图通过IDE(VS2008)来执行它,它的工作原理确定...
这就是我在main
方法做:
static void Main(string[] args)
{
int choice = 0;
if (args.Length == 0)
choice = 1;
else
choice = 2;
switch(choice)
{
case 1:
string[] text = Directory.GetFiles("allText");
Console.WriteLine(DateTime.Now.ToString());
foreach (string fileName in text)
{
string substring = fileName.Substring(8);
ReadData_Logic rd_l = new ReadData_Logic(substring);
rd_l.runThreadsAndDecrypt();
rd_l.printKey(substring.Substring(0, fileName.Length - 15).Insert(0, "encryptedKey\\") + "_result.txt");
}
Console.WriteLine(DateTime.Now.ToString());
break;
case 2:
Console.WriteLine(DateTime.Now.ToString());
string fileName = args[0];
Console.WriteLine(fileName); **<--- for debug, here i do see the correct file name**
ReadData_Logic rd_l = new ReadData_Logic(fileName);
rd_l.runThreadsAndDecrypt();
rd_l.printKey(fileName + "_result.txt");
Console.WriteLine(DateTime.Now.ToString());
break;
}
}
有什么不好的代码? 谢谢
你是否传递文件的完整路径为:“C:\ My Documents \ MyFile.txt”?
如果该文件位于执行cmd /运行应用程序的相同目录中,则只能将文件名称传递为MyFile.txt。
,注意那些带有空格的路径,比如'C:\ My Documents ......'! – 2010-03-31 18:57:29
是的,marc_s是正确的......注意带有空格的路径......把“”作为路径传递到文件中,如“C:\ My Documents \ MyFile.txt”。 – 2010-03-31 19:00:14
会发生什么/是什么鬼输出,当你添加的这几行:
static void Main(string[] args)
{
Console.WriteLine("Count of arguments: {0}", args.Length);
int choice = 0;
if (args.Length == 0)
choice = 1;
else
choice = 2;
Console.WriteLine("Choice now is: {0}", choice);
你明白了什么???
修复了这个问题, 非常感谢 – Igal 2010-05-06 21:42:25
请告诉我们它是如何失败的。你得到什么样的错误/异常? – 2010-03-31 18:43:04
你如何从cmd.exe启动你的应用程序?向我们展示一个例子!怎么了? – 2010-03-31 18:58:39