Question

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.

Was it helpful?

Solution

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" />

OTHER TIPS

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).

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.

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