Я не могу выполнить свое приложение через 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;
}
}
Что не так с кодом?
спасибо