Post

Replies

Boosts

Views

Activity

Reply to Access all files in UIDocumentPickerController while picking folder
Let me give more precisions: If I call startAccessingSecurityScopedResource on the URL of the directory, it's working (return true). The startAccessingSecurityScopedResource returning false happen when I call it on a file URL. So: First, I get the directory URL with UIDocumentPickerViewController configured with .folder as UTTYpe. I try to list recursively all files in this directory, using FileManager with code below (working) func listFilesRecursively(at url: URL) -> [URL] { var newUrls: [URL] = url.hasDirectoryPath ? [] : [url] if url.hasDirectoryPath && url.startAccessingSecurityScopedResource() { let fileManager = FileManager.default let enumerator = fileManager.enumerator(at: url, includingPropertiesForKeys: nil) while let fileURL = enumerator?.nextObject() as? URL { newUrls.append(fileURL) } url.stopAccessingSecurityScopedResource() } return newUrls } I try to process each file's URL to read files in my app, making a startAccessingSecurityScopedResource on file's URL. It's where I'm getting false as returned value.
Aug ’23