I am not able to get actual free storage space from iPhone device. I am using this link to get storage space in xamarin forms ios. Following is my code from the link.
public double GetRemainingInternalMemoryStorage()
{
NSFileSystemAttributes applicationFolder = NSFileManager.DefaultManager.GetFileSystemAttributes(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));
var freeSpace = applicationFolder.FreeSize;
var totalSpace = applicationFolder.Size;
Console.WriteLine("totalSpace " + freeSpace);
return freeSpace;
}
I am working on the functionality where I need to saw user an alert if storage space is less than a threshold value. I am not getting accurate storage space so my functionality is not working.
My device has total 32 GB storage memory but when I check with above code, it saw 31989469184 bytes which is near 31.98 GB (31989469184/1000/1000/1000) which looks near to correct.But similarly Device's free space is 14.2 GB and with above code it saw 12259602432 bytes which is near 12.25 GB. I am not sure why it is giving 2 GB less.
Above linked android code works well. How can I calculate accurate free space in iOS?