0

I need set hidden .exe.config that actually resides in application folder. Alternatively, it would good change folder location, example in application data (hidden folder).

J. Steen
  • 15,470
  • 15
  • 56
  • 63
Vincenzo Lo Palo
  • 1,341
  • 5
  • 19
  • 32
  • Since you didn't look at the related topics before posting this question I have to downvote this question: http://stackoverflow.com/questions/5657821/change-the-store-location-of-application-setting-file?rq=1 – Security Hound Jan 29 '13 at 12:42
  • Im sorry, but this topic not help me to understand how modify location of this file (exe.config) in Visual Studio 2010. – Vincenzo Lo Palo Jan 29 '13 at 12:59
  • The point of sending you to that question was to point out there can only be 3 locations for the configuration file. Besides one of those locations is already the `Application Data` folder. – Security Hound Jan 29 '13 at 13:18
  • Default config.exe is stored in Application folder, not Application Data. At any rate, in my application windows form I dont know what do to change this location – Vincenzo Lo Palo Jan 29 '13 at 13:28
  • Thats only true if you don't set it to the roaming profile option. As how to do it the question I linked to explains your options and the support article on configuration manager class explains the rest. – Security Hound Jan 29 '13 at 13:36

1 Answers1

3

You cannot change the location of the app.exe.config file with the default CLR host. It initializes the primary appdomain with the values it finds in the .config file before your code starts running. There's only one place it will look for the file, in the same directory as the startup EXE, using the name of the EXE. Altering the location is technically possible but only if you write a custom CLR host that uses a custom AppDomainManager. Writing a custom CLR host requires COM code written in C++. This otherwise defeats the point of having only a single deployable file.

If you intend to do this to hide sensitive information, like the username+password for a dbase connection string, then keep in mind that security through obscurity is not true security.

If you intend to do this to achieve single-file deployment then don't forget to overlook the standard solution: a single file named setup.exe

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536