Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User Settings vs Application Settings vs Resources in Visual Studio 2008

I'm a little confused by the different ways Visual Studio allows dynamic values to be saved to a project, and how they are intended to be used.

I understand that if I need to include binary information like an image or a sound file with my application I need to add that to a resource file. But if I'm saving something like a file path as a string why should I use or not use a string in a resource file over a string in an application settings (app.config) file or a user settings (myapp.dll.config) file?

like image 829
Eric Anastas Avatar asked Feb 24 '10 03:02

Eric Anastas


People also ask

What is a resource in Visual Studio?

Applies to: Visual Studio Visual Studio for Mac Visual Studio Code. Resource files are files that are part of an application but are not compiled, for example icon files or audio files. Since these files are not part of the compilation process, you can change them without having to recompile your binaries.

Where is Visual Studio user settings?

Settings. settings is located in the My Project folder for Visual Basic projects and in the Properties folder for Visual C# projects. The Project Designer then searches for other settings files in the project's root folder. Therefore, you should put your custom settings file there.

Where are application settings stored?

User-scope settings are stored in the user's appdata folder. Application-scope settings are stored in C:\Users\My Name\AppData\Local\My_Company\. If your settings file doesn't contain any Application-scope settings, you won't have a company folder.

What is app config in Visual Studio?

App. Config is an XML file that is used as a configuration file for your application. In other words, you store inside it any setting that you may want to change without having to change code (and recompiling). It is often used to store connection strings.


2 Answers

Sorry for the resurrection, but there's another factor to consider that I don't think has been mentioned:

Users can tamper with config to their hearts content - which means that you either have to validate the values in there, or ensure that whatever uses them doesn't care if they're nonsense. I doubt resources files are incorruptible either - I know it's possible to extract values from them, but whether or not it's possible to replace them without recompiling, I don't know. In any case, if you don't want the user changing those values without a concerted effort, go for resources. If you want to enable or even encourage after-market tweaking of settings, go for app settings.

like image 153
Tom W Avatar answered Nov 15 '22 21:11

Tom W


Typically it is better to use a config file for things that are likely to change with every deployment. That way if you ever need to change that file path, you won't need to recompile.

like image 34
Blanthor Avatar answered Nov 15 '22 20:11

Blanthor