Hello,
Please use the CreateDirectory
and Remove
method of NSFileManager
.
Apple's API: createFileAtPath:contents:attributes: | Apple Developer Documentation
try {
var iCloudDocumentsURL = NSFileManager.DefaultManager.GetUrlForUbiquityContainer(null);
if (iCloudDocumentsURL != null) { var path = iCloudDocumentsURL.ToString().Replace("%C3%97", "x");
var filepath = path.Replace("file://", string.Empty).Replace("%20", " ");
var destinationdirectoryPath = Path.Combine(filepath, "MyAppDocuments");
NSFileManager.DefaultManager.CreateDirectory(destinationdirectoryPath, true, null);
if (Directory.Exists(destinationdirectoryPath)) {
NSError err = new NSError();
NSFileManager.DefaultManager.Remove(destinationdirectoryPath,out err);
}
else
{
}
}
} catch (Exception ex) {
Console.WriteLine("--------");
}
If you want to save the document, please refer to Using iCloud with Xamarin.iOS - Xamarin | Microsoft Learn (Xamarin support has been ended, this Doc applies to MAUI)
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.