How to get all files and folders in Xamarin iOS ICloud

Natarajan Tulasi 21 Reputation points
2021-08-26T09:07:47.487+00:00

Hi,

I am creating app for iOS which need to access all files in iCloud.

I trying this

void GetFiles()
{
var uburl = NSFileManager.DefaultManager.GetUrlForUbiquityContainer(null).Append("Documents", true);
var path = uburl.Path;

        if(NSFileManager.DefaultManager.FileExists(path))
        {

            var enumurator = NSFileManager.DefaultManager.GetEnumerator(path);

            NSObject file;
            while((file = enumurator.NextObject()) != null)
            {
                Console.WriteLine("yyy Yes iCloud! {0}", file);
            }
        }
    }

UbiquityContainer returns path but GetEnumerator don't have any paths.

I am struggling here. Please anyone help.

Thanks

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,293 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Natarajan Tulasi 21 Reputation points
    2021-08-31T06:48:09.697+00:00

    I thought NSFileManager.DefaultManager.GetDirectoryContent will get all files and folders in iCloud Drive. but it does get only the files in the container.

    After copying some files to container, NSFileManager.DefaultManager.GetDirectoryContent returns files.