The app will throw an exception when writing to the install folder when debugging from Visual Studio. You need to create and install the MSIX package.
- Create the app package (MSIX)
- Install the app package
Note: In the Start menu you'll see two apps: HelloWpf and HelloWpf1.
- Start HelloWpf
- Click Write
- Start HelloWpf1
- Click Read
HelloWpf1 reads the file created by HelloWpf in the Install folder
To set up redirection for all apps in the same MSIX package add the capability packageWriteRedirectionCompatibilityShim to your Manifest.Package file as follows:
<Capabilities>
<rescap:Capability Name="packageWriteRedirectionCompatibilityShim" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
This will reroute all file writes/reads to/from the install folder to AppData. Here are the relevant docs: App capability declarations - UWP applications | Microsoft Docs