954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Cant run application (C#) through cmd

Hey,
I cant execute application through cmd, when the application trying to read the argument which was sent to it (text file), it fails...
when i'm truing to execute it through the IDE (vs2008), it works ok...

that's what i did in the main method :

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); <strong><--- for debug, here i do see the correct file name</strong>
                        ReadData_Logic rd_l = new ReadData_Logic(fileName);
                        rd_l.runThreadsAndDecrypt();
                        rd_l.printKey(fileName + "_result.txt");

                        Console.WriteLine(DateTime.Now.ToString());
                    } break;
            }
            
        }


what wrong with the code ?
thanks

igalep132
Newbie Poster
5 posts since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

>what wrong with the code ?

Maybe you need to verify the code of ReadData_Logic.

Run your program at cmd,

c:\folder>programName c:\xyz\file.txt
__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: