Hello,
I have recently updated my plugin libraries - specifically Xamarin.Forms from build 4.8.0.1560 to 5.0.0.1905
AND Xamarin.Essentials build 1.5.3.2 to 1.6.1
Prior to the update, this code WAS working AND I could go into the Files app and find the files created by my app under a folder with my app name.
//NOTE - .pngs and .pdfs get saved to the app folder in FILES.
public async void SavePNG(byte[] pngByte, string fileName)
{
await SetPermissions(); //gets/sets permissions to access file-storage
if (Status == PermissionStatus.Granted)
{
try
{
var filePath = Path.Combine(GetDocumentsPath(), fileName);
// save the data to a stream
using (var stream = File.OpenWrite(filePath))
{
stream.Write(pngByte); //create the .png file
}
}
catch (Exception ex)
{
}
}
}
public string GetDocumentsPath()
{
return = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); //was visible to the user in Files (iOS)
}
This is also set in the info.plist:
LSSupportsOpeningDocumentsInPlace boolean Yes
I have double checked information in this link:
https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/file-system#Application_Directories
if I put a breakpoint in and get the filepath var once it is set, it is this:
/var/mobile/Containers/Data/Application/405FF468-9648-44E5-AAC5-92A3D44EB45D/Documents/Sharable4.png
That GUID in the path is wrong methinks.
This Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) is no longer returning the correct path.
This has broken a release today as this was not on the radar for any change and has only been detected post-release.
Tested on both iPad 5th gen and iPhone X. Same issue in both yet this was working prior to plugin updates.
If I go into Setting/General/iPad Storage then select my app in the list of apps, the .png file I export IS listed under DOCUMENTS in the app but it is not accessible and does not show up in Files.
Can someone, ANYONE, please enlighten me on changes to saving files on an iOS device AND making that findable/accessible from the Files app
Thanks very much!