So I was making a polynomial simplifier for my school project. I decided to make the application using C++ UWP in Visual Studio.
As one of the extra features of the application I implemented a system to store and retrieve polynomials from a file so that you can access your previously entered polynomials. I am using boost::filesystem
for this. The code compiles fine. But while debugging, this function:
fs::exists(basePath) // namespace fs = boost::filesystem
...is somehow causing the following exception:
Unhandled exception at 0x00007FFBB71AAFEC (ucrtbased.dll) in ExpressionSimplifierV4 UWP.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.
..thrown from this line:
rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments); // App.xaml.cpp
What is the cause of this exception, and how do I resolve it?
When writing UWP applications, be aware that they by design run in a 'locked-down' environment. One aspect of this is that they have very limited access to the file system.
A UWP application by default has:
read-only access to its own installed directory (which is typically the 'current working directory' at start-up). This is pointed to by Windows.ApplicationModel.Package.Current.InstalledLocation
.
read/write access to its own per user application data directory. The non-roaming version is ApplicationData.Current.LocalFolder
. The roaming version is ApplicationData.Current.RoamingFolder
.
read/write access to a per user application temporary directory that may or may not be there on future invocations of the application. This is ApplicationData.Current.TemporaryFolder
.
Any attempt to access a file folder other than those above by default will fail.
See Microsoft Docs.