Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

Put the file in

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

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top