Click here to Skip to main content
15,945,939 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created a application in c# which execute file in cmd and store the output in text file and then displays it.This runs well on one PC ,but if i take it to some other PC it gives me file not found error .Please help me out in this

What I have tried:

strCmdText = "/C"+textBox1.Text + " --gtest_list_tests>>PathForGtest.txt";
           System.Diagnostics.Process.Start("CMD.exe", strCmdText);

string h=Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"PathForGtest.txt");
            System.IO.StreamReader file = new System.IO.StreamReader (h);

            while ((fileLine = file.ReadLine()) != null)
                if ((fileLine.EndsWith(".")))
                    buffer = fileLine;
                    line = fileLine.Trim();
                    propertyNode = propertyNode + 1;
                propertyName = buffer + line;
Updated 30-Aug-17 19:50pm

1 solution

The first thing to do is find out which file it is complaining about: use try...catch blocks to catch the Exception object and report it's error, complete with any inner exception detail.

When you know that, and where in your code the error is coming from, you can start looking at why - but finding out which file is the first priority.
Until you can isolate that, you are just guessing. And we can't do that for you!
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900