简体   繁体   English

App.config中的相对路径指向另一个项目

[英]Relative path in App.config is pointing at a different project

I have a Visual Studio 2015 project. 我有一个Visual Studio 2015项目。 Let's say it's at this directory: 假设它在以下目录中:

C:\Project\Project A

I then copied and pasted it this new location: 然后,我将其复制并粘贴到此新位置:

C:\Project\Project B

In my App.config file, I have a relative path to a file in the project. 在我的App.config文件中,我有一个指向项目中文件的相对路径。 However, in Project B, that relative path is pointing to Project A. How can I fix this? 但是,在项目B中,该相对路径指向项目A。如何解决此问题?

By default your app will look for the config file in the same dir as its running from. 默认情况下,您的应用程序将在与运行源文件相同的目录中查找配置文件。 But if you want to specify a path of the config file you can do so in the constructor like this: 但是,如果您想指定配置文件的路径,则可以在构造函数中这样指定:

AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", ConfigFilePath)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM