Not able to perform read and write operations in iCloud in .Net MAUI Mac

I have set up the app identifier in Apple developer with the document URL set up for iCloud and also updated the info.plist file and entitlements according to this.

info.plist


<dict>

    <key>iCloud.com.abc.MyApp</key>

    <dict>

        <key>NSUbiquitousContainerIsDocumentScopePublic</key>

        <true/>

        <key>NSUbiquitousContainerName</key>

        <string>MyApp</string>

        <key>NSUbiquitousContainerSupportedFolderLevels</key>

        <string>Any</string>

    </dict>

</dict>



<key>UIFileSharingEnabled</key>

<true/>



<key>LSSupportsOpeningDocumentsInPlace</key>

<true/>



<key>UIBackgroundModes</key>

<array>

    <string>fetch</string>

    <string>remote-notification</string>

</array>



<key>NSUbiquitousContainersUsageDescription</key>

<string>This app uses iCloud containers to store and sync documents.</string>

Entitlement.plist


    <array>

        <string>iCloud.com.abc.MyApp</string>

    </array>

    <key>com.apple.developer.icloud-services</key>

    <array>

        <string>CloudDocuments</string>

    </array>

    <key>com.apple.developer.ubiquity-container-identifiers</key>

    <array>

        <string>iCloud.com.abc.MyApp</string>

    </array>

// Then I am using iCloud for CRUD operation in the app

// Code snippet


    {

        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");

                if (Directory.Exists(destinationdirectoryPath))

                {

                    Directory.Delete(destinationdirectoryPath, recursive: true);

                }

            }

        }catch(Exception ex) {

            LogHandler.LogError(ex);

        }

    }

But in Delete operation gives Exception -> System.IO.IOException: Access to the path '/Users/USERABC/Library/Mobile Documents/iCloudcomabc~MyApp/MyAppDocuments' is denied.