How can I save persistent user settings without using My.Settings (or a text file)?

  • Thread starter Thread starter ShannonM42
  • Start date Start date
S

ShannonM42

Guest
Hello,

I'm looking for ideas on how to save a "default" file without using My.Settings. The specifics are as follows:

Me: I'm a beginner/intermediate user who has used VB on and off since it first came out (and lots of other BASIC programs before that). But it's always been a hobby at best, never a job, and completely self taught so there are lots of gaps in my knowledge.

The project: I'm writing a Windows Forms App with VS2019 to be used on Windows computers by only a handful of people. The users want a standalone exe (no installer, they already have the .NET framework) that will read through thousands of files which are of one specific type. These files have headers that contain keywords with info about the file. My application will let the users chose which keyword/value pairs they want to export to a CSV file so it can be read in to Excel and sorted any way they want. The users do NOT want the app to create additional folders anywhere else on their system but it's OK if the exe needs or creates additional files in the root directory of the exe.

What persistent user info I need to save: The user needs the ability to save a list of keywords for export, two paths to directories, and a few other strings. Things like the form's position, fonts, etc are not required but it would be great if I could save those, too.

The problem: I have the app working perfectly using My.Settings, but that creates the user.config file in a location like C:\user\<username>\appdata\local\<myappname>\version\ or something similar. I can't have my app creating a directory in that location or using a file from there. I could save all of these settings with a text file, but it seems like a lot of room for error. They don't all get saved at once; a user may change one setting at one point and another later on. I'd like to learn a better way.

What I'd like the most: The best solution for this specific problem would be to change the location of where the user.config file is saved from "MachineToLocalUser" to "MachineToApplication". It looks like the location of the user.config file is handled by AllowExeDefinition, but I don't understand enough about the VB Namespaces to make the change.

Other options: I found this article explaining how to make a custom user settings file, but it's above my head.
Manage application settings (.NET) - Visual Studio

Another option would be to create my own XML file to hold the settings but this requires making a class to handle the get/set to XML which I don't know how to do yet.

My biggest frustration with Microsoft Docs is that most of the examples are in C#. Is there a way to view the Docs so the examples are for Visual Basic?

If anyone has any comments or suggestions, I would sincerely appreciate any help or advice offered. Learning a way to solve this issue will add a lot to my VB knowledge toolkit.

Thank you,
Shannon

Continue reading...
 
Back
Top