Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify path in .config file relative to the file?

An app I use interprets a .NET .config file. I added a line specifying the path to a certificate it needs

<add key="Certificate" value="..\certificate.abc"/>

However, I found the app only works when run from the exact folder its .exe and .config reside. If run from another folder, it fails, because it looks for the certificate at ../ expanded relative to the working directory.

What should I write in the config file, to make sure the path is ..\certificate.abc expanded relative to the config file rather the working directory?

I can't change the app (it's not mine), I can only change the config file.

like image 611
Colonel Panic Avatar asked Apr 23 '13 11:04

Colonel Panic


People also ask

How do you set the path of a file?

Click the Start button and then click Computer, click to open the location of the desired file, hold down the Shift key and right-click the file. Copy As Path: Click this option to paste the full file path into a document. Properties: Click this option to immediately view the full file path (location).

What is the file path of a file?

A file path describes the location of a file in a web site's folder structure. File paths are used when linking to external files, like: Web pages. Images.

Which element in the path is the file path?

An absolute path always contains the root element and the complete directory list required to locate the file. For example, /home/sally/statusReport is an absolute path. All of the information needed to locate the file is contained in the path string.


2 Answers

By using the tilde

value="~/certificate.abc"
like image 160
SpaceApple Avatar answered Oct 03 '22 23:10

SpaceApple


In visual studio 2015, the "~" keyword has no longer worked. You can now use :

value="folder\subfoler"

"folder" has the same level with .exe file

like image 45
Hai Hoang Avatar answered Oct 04 '22 01:10

Hai Hoang