I have an application which reads a file from its own programs files folder; The application assumes it get's started in that specific folder, the local current directory. (Currently it crashes, as the file is required, and not found).
Current directory: C:\Windows\system32
Error reading file f.dat
Using other Installers like Wix
and InnoSetup
one can create the shortcuts, with their specific start in
folders.
How do solve this? Is it possible to set the start in
folder for the Application, using the Visual Studio Windows Application Packaging Project
, which generates the MSIX
installer.
I am thinking of determining the install folder at runtime, and then to read the file using an absolute path. Perhaps there is some documented registry entry I should query.
The solution is to not rely on the "start in" folder, but to use the path of the running process.
In my specific case I am using
Go
(Golang). Using os.Executable()Here is my old code which failed when using
MSIX
:And the new code: