问题
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