WPF save settings

Today I created an application in which the user can create an image with the background color and the name chosen by him. But now I am faced with this problem: when I try to save the settings (My.settings.bgcolor.save ()), it saves the color, but I can not see it in the WPF Project β†’ Settings (it does not appear there and it does not appear in the settings .setting, but the application loads the new content). Any ideas?

Code as requested:

If (site.Text <> Nothing And num_tile.Text <> Nothing And cul <> Nothing) Then My.Settings.shortcuts_bgcolor.Add(cul) My.Settings.shortcuts_name.Add(num_tile.Text) My.Settings.shortcuts_website.Add(site.Text) Dim i As Integer = 0 For Each shc As String In My.Settings.shortcuts_name MsgBox(My.Settings.shortcuts_name(i), MsgBoxStyle.Information) i += 1 Next Dim window As MainWindow = New MainWindow window.IncarcaButoane() Me.Close() End If End Sub Private Sub Window_Closing(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing My.Settings.Save() End Sub Private Sub Window_Closed(sender As System.Object, e As System.EventArgs) Handles MyBase.Closed My.Settings.Save() End Sub 
+4
source share
1 answer

The values ​​that you see in the project settings are the default values ​​- if the application applies the changes, they are not saved in this file. For the actual location of user preferences, the first place I would look is under %userprofile%\AppData\Local or %userprofile%\AppData\Roaming (in the subfolder of your application "Company Name"). However, keep in mind that the actual location of the file depends on the user profile and type of application :

The location of the app.exe.config and user.config files will differ depending on how the application is installed. For a Windows Forms-based application copied to the local computer, app.exe.config will be in the same directory as the base directory of the main executable file of the application, and user.config will be in the location specified in the application :: LocalUserAppDataPath Property. For an application installed using ClickOnce, both of these files will be located in the ClickOnce data directory under% InstallRoot% \ Documents and Settings \ username \ Local Settings.

The storage location of these files is slightly different if the user has roaming profiles enabled, which allows the user to define various Windows and application settings when he or she uses other computers in the domain. In this case, ClickOnce applications and applications other than ClickOnce will have the app.exe.config and user.config files stored in the% InstallRoot% \ Documents and Settings \ username \ Application Data folder.

+5
source

Source: https://habr.com/ru/post/1489576/


All Articles