Where are My.Settings saved in VB 2010 .NET?

╄→гoц情女王★ 提交于 2019-11-26 09:53:11

问题


Are My.Settings values saved in the program itself or do they get stored in the registry? So, for example, if I set a My.Settings value with a program, then I copy the program itself to another PC - is the My.Settings value still set?


回答1:


It depends upon the scope you have selected. There are two scope settings - Application and User scope.

From MSDN article:

Application-scoped settings are read-only and are shared between all users of that application. These settings are stored in the app.config file in the section. At run time, the app.config file will be in your bin folder and will be named with your application's name (MySettingsDemo.exe.config).

User-scope settings are specific for each user. They can be read and set safely by the application code at run time. These settings are stored in a user.config file. To be technically accurate, there are two user.configs per user per application—one for non-roaming and one for roaming. Although the Visual Basic 2005 documentation states that the user.config file will be named according to the user's name (joe.config), this is not the case. The user.config file is created in the:

<c:\Documents and Settings>\<username>\[LocalSettings\]ApplicationData\<companyname>\<appdomainname>_<eid>_<hash>\<verison>.



回答2:


Dim config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
MessageBox.Show(config.FilePath)



回答3:


If you have installed your application using clickonce then your MySettings will be stored in a config file which is stored at `C:\Users\\AppData\Local\Apps\2.0\Data........

search in these path with a file named as yourapp.exe.config

The thing is MySettings will be stored in app.config file of that application and after publishing the app.config file is saved as applicationname.exe.config file




回答4:


They're definitely not stored within the program if they're User settings - that's not very easy to implement, and rather pointless. Rather, they're stored in a configuration file in the %AppData% folder. So no, if you copied the program, the User settings wouldn't come with it, just the Application settings.



来源:https://stackoverflow.com/questions/8691858/where-are-my-settings-saved-in-vb-2010-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!