如何创建User.config以及如何使用它 [英] How is User.config created and how it is used

查看:86
本文介绍了如何创建User.config以及如何使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始阅读有关配置文件的内容,也阅读了有关user.config的内容.搜索了它,但是找不到如何创建和使用它.另请注意,将为每个用户创建一个单独的user.config.甚至在StackOverflow中阅读了问题,但它们并没有帮助.谁能指出我正确的资源.在此先感谢:)

I started reading about config files and I read about user.config. Googled about it, but couldnt find how it is created and how it is used. Also read that for each user a seperate user.config will be created. Even read questions in StackOverflow, but they didnt help. Can anyone point me to the right resources. Thanks in advance :)

感谢@Ramesh,@Michael和@Frozendragon的回答.彻底浏览了您发布的文章.假设我有一个Web应用程序,并且有3个名为"A","B"和"C"的用户正在使用它们.我有一个app.config,其中提供了默认值.保存在UserName.config文件中,这是我迷路的地方如果将值保存在相应的用户配置文件中,当同一用户再次尝试打开该应用程序时,如何取回这些值?我的应用程序如何知道哪些文件看吗?

Thanks @Ramesh , @Michael and @Frozendragon for your answers. Gone through the articles posted by you. Assume that I have a web application and 3 users named "A", B" and "C" are using them. I have an app.config in which i provided default values. I read that those values can be changed accordinly and will be saved in the UserName.config files. This is where I am lost. If the values are saved in the corresponding user profiles, how are they fetched back when the same user tries to open the app again ? How does my app knows in which files to look ?

推荐答案

回答如何创建User.config文件"的后续问题:

To answer the follow-up question of 'How do the User.config files get created':

当您打开具有用户范围设置的桌面应用程序时,.NET Framework将自动尝试从用户的本地应用程序目录中为您加载User.config文件-检查 SpecialFolder.ApplicationData )获取当前用户的确切目录.

When you open a Desktop application with User-Scoped settings, the .NET Framework will automatically attempt to load the User.config file for you, from the user's Local Application directory - examine the value of Environment.GetFolderPath(SpecialFolder.ApplicationData) for the exact directory for the current user.

如果文件不存在,则将创建它.

If the file does not exist, then it will be created.

我没有确切的资源要指向您,因此创建该文件的确切时间可能是未找到该文件的时间,或者仅当您在ApplicationSettings实例上调用Save时才可能.

I don't have exact resources to point you at, so the exact time when that file is created may be if it's not found, or it may only be if you call Save on the ApplicationSettings instance.

这篇关于如何创建User.config以及如何使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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