VB.NET 2015+ Best place to save application scope data

In VB.NET, where is the best place to save application scope data?  I am looking to save one or more data files to be used to persist application-level settings and configurations between different users.

This doesn't seem to work as each user as Windows seems to call up their own virtual copy of the file.
      Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

My.Settings only works for user-scope settings.  The application-scope settings get reset when the application is reloaded ... i.e. the data doesn't persist.
eeyoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
There are Application level settings, but those are typically set at design or deployment, and a standard user would not be able to change/add to those because of UAC. .NET offers the ConfigurationManager, but you're liable to run into the same issue with UAC.

You can always use the registry to store those, but you may also run into UAC issues with that as well.

You can resort to the old INI file approach, or something similar. I use an XML file stored in the Roaming\<NameOfMyProgram>, which seems to work fine.
0
eeyoAuthor Commented:
Would this be the appropriate path for the "Roaming" folder (+\ + NameOfMyProgram)?
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

Open in new window

gives me C:\Users\<user name>\AppData\Roaming but that folder and the files within it would be different if another user logged in.
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
That's the right way to get the Roaming folder, but for Application data I'd suggest using a different location:

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

Here's an article that lists all the SpecialFolders available:

https://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=vs.110).aspx
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

eeyoAuthor Commented:
I figured out what one of my problems was.  I was using ClickOnce which uses a strange virtualized folder.  I went through the ordeal of figuring out that I needed to download the Visual Studio Installer (doesn't come standard).  I will try to tinker with it more now ...
0
eeyoAuthor Commented:
So, I just tried using Environment.SpecialFolder.CommonApplicationData (C:\ProgramData\ in Win 10).  Reading and writing files there are fine if you are an admin user, but if you log in as a standard user, you will get an access denied error.  Any other thoughts?

I even tried adding a custom "MyConfig.xml" file to the Project (selecting "Copy to Output Directory"), which means it installs in the startup directory.  Even the admin user that installed the application can't write to this custom file.

Any other thoughts?
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Only other thing I could suggest would be either (a) a database or (b) a Public Document folder for your xml file.
0
eeyoAuthor Commented:
Any thoughts about these possibilities:

1) Using the good old Windows Registry?  Is there a reason why it has fallen out of favor?  In this case, I might have to dump an XML file into one of the registry keys.  Is there a max string length for registry keys?
2) Creating a Resource file (Project menu -> Properties -> Resources tab -> Add Resource -> Add Existing File) such as a .txt or .xml file, then editing this resource file at runtime?  Hopefully this would allow any user (including windows "Standard Users") to edit this resource file.  I tried to implement this but couldn't figure out how.
0
eeyoAuthor Commented:
You can resort to the old INI file approach, or something similar. I use an XML file stored in the Roaming\<NameOfMyProgram>, which seems to work fine.
Scott, was this for user or application scope data?
0
eeyoAuthor Commented:
While there is no perfect solution to this, this may be the best one for now:
Environment.SpecialFolder.CommonApplicationData (C:\ProgramData\ in Win 10)
It still requires the user to have admin rights, unfortunately.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.