我如何获得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屋!
查看全文