获取当前配置文件的文件名 [英] Get filename of current configuration file

查看:31
本文介绍了获取当前配置文件的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这很简单,但我找不到答案.

I'd think this would be simple, but I can't find an answer.

我正在使用远程处理并且我想将 RemotingConfiguration 存储在 app.config 中.当我调用 RemotingConfiguration.Configure 时,我必须提供远程信息所在的文件名.所以...我需要知道当前配置文件的名称.

I'm using remoting and I want to store the RemotingConfiguration in the app.config. When I call RemotingConfiguration.Configure I have to supply the filename where the remoting information resides. So... I need to know the name of the current configuration file.

目前我正在使用这个:

System.Reflection.Assembly.GetExecutingAssembly().Location + ".config"

但这仅适用于 Windows 应用程序,不适用于 Web 应用程序.

But this only works for windows applications, not for web applications.

没有任何类可以为我提供当前配置文件的名称吗?

Isn't there any class that can supply me with the name of the current config file?

推荐答案

Try AppDomain.CurrentDomain.SetupInformation.ConfigurationFile

https://docs.microsoft.com/en-us/dotnet/api/system.appdomainsetup.configurationfile

这篇关于获取当前配置文件的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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