gpt4 book ai didi

.net - WPF 保存设置

转载 作者:行者123 更新时间:2023-12-04 03:45:18 31 4
gpt4 key购买 nike

今天我创建了一个应用程序,用户可以在其中创建具有他/她选择的背景颜色和名称的图像。但现在我面临这个问题:当我尝试保存设置(My.settings.bgcolor.save())时,它会保存颜色,但我无法在
WPF项目>>设置(它没有出现在那里,也没有出现在settings.setting中,但应用程序加载了新内容)任何想法?

按要求编码:

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

最佳答案

您在项目设置中看到的值只是默认值——如果应用程序应用更改,它们不会保存到该文件中。对于用户设置的实际位置,我首先要看的是%userprofile%\AppData\Local下或 %userprofile%\AppData\Roaming (在您的应用程序的“公司名称”子文件夹下)。但是,请记住 the actual file location varies depending on the user's profile, and on the application type :

The location of the app.exe.config and user.config files will differ based on how the application is installed. For a Windows Forms-based application copied onto the local computer, app.exe.config will reside in the same directory as the base directory of the application's main executable file, and user.config will reside in the location specified by the Application::LocalUserAppDataPath property. For an application installed by means of ClickOnce, both of these files will reside in the ClickOnce Data Directory underneath %InstallRoot%\Documents and Settings\username\Local Settings.

The storage location of these files is slightly different if a user has enabled roaming profiles, which enables a user to define different Windows and application settings when he or she is using other computers within a domain. In that case, both ClickOnce applications and non-ClickOnce applications will have their app.exe.config and user.config files stored under %InstallRoot%\Documents and Settings\username\Application Data.

关于.net - WPF 保存设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17456880/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com