【问题标题】:Access the path to the app.config programmatically以编程方式访问 app.config 的路径
【发布时间】:2010-04-26 13:31:26
【问题描述】:

我正在寻找一种从 Windows 服务可执行文件中以编程方式获取 app.config 文件路径的方法。 构建过程将App.config 更改为program-name.exe.config,我可以执行以下操作:

var configFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "program-name.exe.config");

但是,我正在寻找某种在运行时获取配置文件名的方法,该方法不涉及将 exe 名称硬编码到应用程序中。 ConfigurationManager有办法做到这一点,所以一定是可以的。

【问题讨论】:

    标签: c# app-config


    【解决方案1】:

    我通常使用AppDomain.CurrentDomain.SetupInformation.ConfigurationFile。虽然没有在 Windows 服务上下文中尝试过。

    【讨论】:

    • 哦,我不知道。对不起。 :)
    猜你喜欢
    • 2012-01-06
    • 1970-01-01
    • 1970-01-01
    • 2014-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-18
    • 2013-05-29
    相关资源
    最近更新 更多