views:

105

answers:

5

I've got many assemblies/projects in the same c#/.net solution. A setting needs to be saved by people using the web application gui, and then a console app and some test projects need to access the same file. Where should I put the file and how to access it?

I've tried using "AppDomain.CurrentDomain.BaseDirectory" but that ends up being different for my assemblies. Also the "System.Reflection.Assembly.Get*Assembly.Location" fail to give me what I need.

Maybe this isn't something I should but in a file, but rather the database? But it feels so complicated doing that for a few lines of configuration.

A: 

Thought about storing it in the registry or in Isolated Storage? Not sure if multiple applications can share Isolated Storage or not, though.

Vaibhav
Not really, they need to be deployed using ClickOnce for that as it seems.
Microserf
What about Registry?
Vaibhav
I don't know. It feels more logical and safe to put it in a database as compared to the registry. Or?
Microserf
Well, I say if you have a database, then yes put them in the database for sure....
Vaibhav
+3  A: 

Put the file in

    Path.Combine(
        Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
        "[Company Name]\[Application Suite]");
Pop Catalin
A: 

registry or database also avoids any file-locking problems

ballpointpeon
A: 

projects can have build events -- why not add a post-build event to copy the file to all required locations?

Steve Cooper
+1  A: 

Personally, I would be leveraging the database because the alternative is either a configuration headache or is more trouble than it's worth.

You could configure each application to point to the same file, but that becomes problematic if you want to move the file. Or you could write a service to manage the file and expose that to clients, but at this point you may as well just use the DB.

HTH, Kent

Kent Boogaart