如何以编程方式获取 user.config 文件的位置? [英] How do I get the location of the user.config file in programmatically?
本文介绍了如何以编程方式获取 user.config 文件的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的 windows 窗体应用程序中显示 user.config 文件的位置,以便用户可以轻松找到它.
I'd like to display the location of the user.config file in my windows forms application so a user can easily find it.
我了解路径是如何创建的,这要归功于:我可以控制 .NET 用户设置的位置以避免在应用程序升级时丢失设置吗?.
I understand how the path is created thanks to: Can I control the location of .NET user settings to avoid losing settings on application upgrade?.
但是,如果这种情况发生变化,我宁愿不必在我的应用程序中构建路径,尤其是如果有一种简单的方法可以获取 user.config 文件位置.
However, in case this changes, I would rather not have to construct path this in my app, especially if there is an easy method for getting the user.config file location.
推荐答案
试试这个:
var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming);
MessageBox.Show(config.FilePath);
这篇关于如何以编程方式获取 user.config 文件的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文