0

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

2
  • 1
    Can you put some example folder structures in please. Your explanation is confusing. Commented Sep 29, 2010 at 4:14
  • I will add this soon. For some reason the code didn't appear also Commented Sep 29, 2010 at 4:25

1 Answer 1

0

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).

Sign up to request clarification or add additional context in comments.

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.