locked
How to save EDITABLE application settings? RRS feed

  • Question

  • 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.

    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?

    Monday, April 1, 2019 10:36 PM

All replies

  • Hi Robert in SF,

    Thank you for posting here.

    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 is the string I defined in the Settings.

    For more details, please refer to the MSDN document.

    https://docs.microsoft.com/en-us/visualstudio/ide/managing-application-settings-dotnet?view=vs-2015

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 2, 2019 8:27 AM
  • Thanks for your response, Wendy. Unfortunately, while Properties.Settings (and My.Settings in VB) is a great feature, the application-level settings are not editable except in the IDE.

    I've concluded there is no way except to use a database or text file or even XML. Fortunately, ReadAllLines makes it easy to read text files.

    Tuesday, April 2, 2019 7:46 PM