I had connected iCloud using xamarin forms ios. My file copied to icloud without any error. But it saved in file:///private/var/mobile/Library/Mobile%20Documents/iCloud~com~companyname~MobileDoc/ path.
When i checked inside iCloud my file not showing it. But when i search that file, its location shows as iCloud --> MobileDoc--> File.txt. But when i checked inside the iCloud there are no Folder call MobileDoc.
This is the example i tried Here
This is the code i am using to save the document.
var uburl = NSFileManager.DefaultManager.GetUrlForUbiquityContainer(null);
if (uburl == null)
{
HasiCloud = false;
}
else
{
HasiCloud = true;
iCloudUrl = uburl;
var docsFolder = Path.Combine(iCloudUrl.Path, "Documents");
var filePath = Path.Combine(docsFolder, fileName);
FileService.Save(filePath, attachment.Content);
if (option == false)
FileService.Instance.Open(filePath);
}
Saving iCloud Documents
To add a
UIDocument
to iCloud you can callUIDocument.Save
directly (for new documents only) or move an existing file usingNSFileManager.DefaultManager.SetUbiquitious
. The example code creates a new document directly in the ubiquity container with this code (there are two completion handlers here, one for the Save operation and another for the Open):According to document ,when you save file to icloud,you need to use
UIDocument
.This will be Safe and stable.