Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am a complete newb to installers, but so far I have made decent progress. I am stuck on one aspect that I can't quite sort out. My installed application has a few files that the executable works with in order to function. I have successfully created shortcuts in places like the desktop and start menu as part of my installer. However I can't get the same type of behavior to work when I add a file type. So if I add the file type, and then set the command to be the primary output found in the application folder, then I would have hoped that would work. However, once I install, I can tell by some error logs I have in my app that it is looking for files relative to the file with the extension I just clicked on, not relative to the application folder. So rather than looking for c:\Programs(x86)\MyCompany\MyApp\Settings.xml it looks for Settings.xml in c:\MyFileFolder\Settings.xml because the file that I clicked was in c:\MyFileFolder.

That obviously causes actions that depend on that file to fail. I can't figure out what I am doing wrong on this. Does anyone know what I am missing? I have followed the steps on some MSDN walkthroughs but they don't say anything that would warn me about this issue. I tried seeing if I could browse to a shortcut that I have created for the installation, but that wasn't working.
Posted

1 solution

The places where you are reading application files like a settings.xml file should be accessed with the following path:
System.AppDomain.CurrentDomain.BaseDirectory+"\\settings.xml" 


That creates a path that will work independent of the working directory the exe is acting in.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900