如何在 .config 文件中指定相对于文件的路径? [英] How to specify path in .config file relative to the file?

查看:42
本文介绍了如何在 .config 文件中指定相对于文件的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的一个应用程序解释了一个 .NET .config 文件.我添加了一行指定它需要的证书的路径

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"/>

但是,我发现该应用程序仅在从其 .exe.config 所在的确切文件夹运行时才有效.如果从另一个文件夹运行,它会失败,因为它在 ../ 中查找证书,相对于工作目录展开.

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.

我应该在配置文件中写什么,以确保路径是 ..\certificate.abc 扩展相对于配置文件而不是工作目录?

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.

推荐答案

使用波浪号

value="~/certificate.abc"

这篇关于如何在 .config 文件中指定相对于文件的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆