c# – NetMaui – iOS – Could not find a part of the path ‘/var/mobile/Containers/Data/Application/


More of an FYI than a question as I’m sure others have found this and there is no mention of it anywhere I can see:

Background: Using NetMaui to build an Android / iOS app. Testing iOS version of app using two methods:

Method 1: iPhone plugged into windows machine, running as Local Device.

Method 2: iPhone plugged into Mac, running paired to windows machine, so running as remote device.

Using two different methods because occasionally get different results, i.e. App Badge doesn’t display correctly in windows local mode, but does in remote mode, so use both methods to track actual issues and IDE / implementation issues).

Problem: When switching between methods, any images stored to local storage become unreachable, when attempting to load an image (var imageBytes = await File.ReadAllBytesAsync(imageUri)) it throws an exception: Could not find a part of the path '/var/mobile/Containers/Data/Application/5DB9D25D-4572-4EB8-B1A2-012E44E64E86/Library/IMAGES/...

Solution: None really. It all works fine up until you run via a different method, at which point all previously saved files become unreachable and this is not recoverable i.e. switching back to other method doesn’t restore accessbility, those files are now completely unreachable forever. Files then added using the current method are fine and continue to be until the method is switched again. Now that I know this is the cause, I’m not really worried as it will likely only be a testing issue. But i’m sure there is someone else out there pulling their hair out trying to figure this out, so I thought I’d share.

  1. Checked all file paths,

  2. Checked Directory permissions,

  3. Iterated over storage to check files still exist in correct location

  4. Checked for known issues

  5. Checked all libraries and dependancies up to date

  6. Cleans, Recompiles, Reboots, App deletion and reinstall

Files that are in the application directory should be accessbile

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img