如何保存EDITABLE应用程序设置? [英] How to save EDITABLE application settings?
问题描述
My.Settings类非常适合处理用户设置。 PropertyGrid控件使编辑设置变得非常容易。但应用程序设置是只读的。它们只能在VS IDE中更改(Community 2017 VB / C#)。这省略了对所有用户应用
的设置以及可以更改的设置,即使不经常。
The My.Settings class is great for handling user settings. The PropertyGrid control makes editing settings very easy. But application settings are read-only. They can only be changed in the VS IDE (Community 2017 VB/C#). This leaves out settings that apply to all users and that can change, even if infrequently.
过去,我一直坚持这些设置我在应用程序启动时读入的文本文件中。额外的好处是可以使用记事本更改设置。我可以继续这样做,但除了My.Settings之外,还有一个替代
.NET吗?
In the past, I've persisted these settings in text files I read in when the application starts. The added benefit is that the settings can be changed with Notepad. I can continue doing it this way, but aside from My.Settings, is there an alternative within .NET?
推荐答案
嗨罗伯特在SF,
Hi Robert in SF,
感谢您在此发帖。
对于您的问题,我建议您使用Properties.Settings。
For your question, I suggest you to use Properties.Settings.
您可以在项目属性>中设置设置。设置。
You could set the settings in the Properties of project> Settings.
以下是供您参考的简单代码。
Here is the simple code for your reference.
Properties.Settings.Default.FileList3 = "Hello";
Properties.Settings.Default.Save();
FileList3是我在设置中定义的字符串。
有关详细信息,请参阅MSDN文档。
For more details, please refer to the MSDN document.
https://docs.microsoft.com/en-us/visualstudio/ide/managing-application-settings-dotnet?view=vs- 2015
最诚挚的问候,
Wendy
这篇关于如何保存EDITABLE应用程序设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!