16

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?

fen
  • 9,835
  • 5
  • 34
  • 57
Eric Anastas
  • 21,675
  • 38
  • 142
  • 236

2 Answers2

16

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.

Tom W
  • 5,108
  • 4
  • 30
  • 52
6

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.

Blanthor
  • 2,568
  • 8
  • 48
  • 66
  • 1
    Ok good point so to change a resource you'd need to recompile, but to change an application/user setting you only need to change the XML settings file. – Eric Anastas Feb 25 '10 at 17:01
  • Correct. Config files are best for storing environment-specific settings, which will depend on the installation. This may include file paths, database connection strings, and URI's for services which may change. This leaves a stable build in tact. – Blanthor Feb 28 '10 at 19:49