views:

55

answers:

1

Hi, I have a test which runs a script. It gets the path from the app.config file:

<scriptsSectionGroup>
    <scriptsCollection>
      <scripts>
        <add name="TestScript" path="C:\My Projects\RestServicePublishing\UtilityFixture\testScript.bat"/>
      </scripts>
    </scriptsCollection>
  </scriptsSectionGroup>

'testScript.bat' is located in the UtilityFixture project. It is not in a subfolder.

UtilityFixture

  • testScript.bat

However I don't want to specify the full path as I have here. I want to make it so that it will find 'testScript.bat' in the project 'UtilityFixture' regardless of what directory the project is sitting it. Say if someone else downloads it from source control to a different location.

To explain this further I want the file to be found if I say moved the 'RestServicePublishing solution to a new folder say "C:\My Projects 2".

Can someone tell me if it is possible?

Thanks

A: 

You don't need to specify a path at all if the script is in the same folder as the executable. Otherwise, you can specify it relative to the EXE,

..\testScript.bat            # in parent folder
scripts\testScript.bat       # in subfolder

In any case, you're right, you certainly don't want to use a "well-known" location (i.e. hardcoded path).

harpo
Tried that but it doesn't seem to check for the file using a relative path to the exe. It actually tries to find ..\testScript.bat without substituting where the project is running from
Mr Cricket