views:

147

answers:

3

I have an App.config file in my project that gets copied to NameOfExe.exe.config at build time. The users of my software will need to edit this file at times, but they may not be familiar with how .NET does things (or how computers do things in general). I think using a file name like that might confuse them, with the .exe.config extension and such.

How can I specify a new name for this copied file (remove the .exe bit)? Should I use a custom build command? Also, will .NET pick up on the config file, or does it require that naming scheme?

EDIT: In response to suggestions to reconsider... the application acts as either a service or a console app, so there's no GUI to edit settings. The configuration file contains settings used to connect to a database and an API service. These values should not need to be changed after the initial setup for each customer (which is done by me). In the unlikely event that the values do need to be changed, the customer will need to call me to get the new connection details anyway, so I can walk them through what to edit and how. I would simply like to avoid any confusion when I tell a customer that they need to open a file called ".exe.config", at which point they launch the ".exe" file by mistake. Also, if they need to launch the .exe file and have "Hide extensions of known file types" enabled, some may try to open the config file and then call me wanting to know why they instead get a Notepad window full of strange text.

Sure, it's not required, but I like to plan ahead.

+2  A: 

Before someone tell you how to change it (it's possible and pretty simple) I urge you to reconsider.

If your users are other developer type people, using .exe.config is perfectly fine. If they're consumers, they shouldn't mess with the .exe.config or other xml-like files. You should provide another means for them to configure the app (settings).

psychotik
+2  A: 

If your users have problems with the name or the extension of the file, how would they ever deal with the XML inside it?

Instead of wasting your energy figuring out whether you can rename the file, give your users a nice GUI they can use to change the relevant configuration.

Mark Seemann
I edited my question to explain further.
David Brown
Thanks for the detailed explanation. You *could* develop another app for editing the relevant configuration values, but from your scenario description, that sounds like extremely poor return of investment. I voted up one of the other answers that seem to better capture what you asked for.
Mark Seemann
+4  A: 

I agree with psychotik that you should reconsider the concept of making your users mess with the configuration file of the software, but you can use this alternative:

It is possible to reference an external configuration file

<appSettings file="otherlessconfusingname.config" />
Pierre-Alain Vigeant
+1 After David Brown's edit, your answer seems to be the best fit.
Mark Seemann
This would work, yes. However, the original problem would still exist (possible confusion with the file name) with the added fact that there are now two different configuration files.
David Brown
Not if you just rely on otherlessconfusingname.config for the user config stuff? You can put whatever you like there to make it less confusing. This is exactly the answer you asked for. The only alternative from here is to do a settings load within your app of someotherfile.whatever but how is that different from this method?
Graphain
My point is, there would still be a .exe.config file, which as I said, may cause confusion. All this does is keep the original config file, complete with the issues I outlined above, and add a second one. I've worked with these customers for a while, so I have a pretty good idea of what might go wrong based on past support calls. I'm just trying to cover all the bases.
David Brown