Change in working directory #2195
Replies: 3 comments 25 replies
-
It works fine for me : |
Beta Was this translation helpful? Give feedback.
-
Oops, thanx for reminding me about this, @BenJKuhn! I should've answered/closed it earlier. Turns out the problem was my misunderstanding how the Windows App environment has changed in some subtle but radical ways from WPF, WinForms, Windows console apps, etc. As I've now learned, by design Windows Apps are installed to c:/Program Files/WindowsApps (which is a hidden folder to boot). Along with that, their "working directory" is c:/system/windows32...which cannot be written to by default. What you have to do instead is utilize the application local folder (maybe roaming is available, too, I'm not in front of my development machine right now to check) to store things like log files, configuration files, etc. Frankly, the documentation in this area is pretty weak. The information is there, but you have to know to look for it to find it. That's probably not a github problem, though. It's more a shortcoming of the Microsoft documentation. |
Beta Was this translation helpful? Give feedback.
-
I'm still a little unclear if the best practice here is for most app developers to change their working directory on app start? I 100% agree that apps should not write, or have permissions to write, to their install folder. But there are read scenarios where I feel this change a little lost. I ran into this issue because a library I'm using includes some datafiles that it reads from during initialization (Yes, they could include it in the binary, but thats not applicable in all scenarios). Because the working directory is What the background on making this change? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I’m migrating my Windows development from WPF to the Windows App SDK (WinUI 3). I’ve noticed the working directory has changed and now always appears to be c:/windows/system32, as defined in Environment.CurrentDirectory when called inside app code.
I’m curious as to why the change was made.
Beta Was this translation helpful? Give feedback.
All reactions