I am developing an C# Visual Studio application and I am using a config.txt file. But when the application is installed on another machine, how can I find the config.txt file path, taking into consideration that the user will install the application on a custom path (C:\Folder X) ?
Share
If the config file is on the same directory that the executable, you could use:
EDIT:
The
GetExecutingAssembly()should have returned the pathC:\Program Files\MyAddIn\your_plugin.dll, as it returns the actual path of the loaded assembly that calls it.As it’s not the case, we could guess MS Project is actually copying your dll into a local (and maybe temporary) directory before loading it (the
....\AppData\Local\Assembly\...path).As I don’t know why and how MS Project does this, the safest way to deal with your problem I think is to store the location of your Addin folder into the registry on installation. If you’re shipping it as an MSI, it should be easy to make your installer adds a registry key that contains your plugin file location. How to do this will depend on how you build your MSI: vdproj? WiX?.
Then in the code of your plugin, you could read into registry to get your path.