CLI commands and path folder. RRS feed

  • Question

  • Hello dear members;

    I'm working in application to load firmware in my microcontrollers using a file .bat provided by Texas Instruments. 

    My application ran with success, however, I`m with path folder problem. 

    My current code is below:

                Process MSP = new Process();
                MSP.StartInfo.WorkingDirectory = @"D:\Projects\Test_Fixture\Test_Fixture_Visual_Studio\uniflash_windows_64";
                MSP.StartInfo.FileName = "dslite.bat";

    In MSP.StartInfo.WorkingDirectory I need to include the precise path for the ".bat" files. 

    How Can I code in C#, in the way that my software will look automatic inside of the same folder of my application?

    Thank you for your attention and best regards. 

    Friday, November 16, 2018 3:41 AM

All replies

  • Try this.

    MSP.StartInfo.WorkingDirectory = System.IO.Directory.GetCurrentDirectory();

    Friday, November 16, 2018 4:13 AM
  • Try this too:

       MSP.StartInfo.WorkingDirectory = Path.GetDirectoryName( Assembly.GetEntryAssembly().Location );

    Friday, November 16, 2018 5:56 AM