UIDocumentPickerViewController with kUTTypeFolder external USB

I created a UIDocumentPickerViewController and picked my folder on USB drive, after listing files with an enumerator, how can i read the contents?


Are you able to read the contents of a file?


Here is my sample code:


@IBAction func readFiles(){
        // Reading the Content of a Picked Folder
        let shouldStopAccessing = pickedFolderURL.startAccessingSecurityScopedResource()
        defer {
            if shouldStopAccessing {
                pickedFolderURL.stopAccessingSecurityScopedResource()
            }
        }
        var coordinatedError:NSError?
        NSFileCoordinator().coordinate(readingItemAt: pickedFolderURL, error: &coordinatedError) { (folderURL) in
            let keys : [URLResourceKey] = [.nameKey, .isDirectoryKey]
            let fileList = FileManager.default.enumerator(at: pickedFolderURL, includingPropertiesForKeys: keys)!
            logString = ""
            for case let file as URL in fileList {
                
                let newFile = file.path.replacingOccurrences(of: pickedFolderURL.path, with: "")
                if(newFile.hasPrefix("/.") == false){ //exclude hidden
                    
                    print(file)
                    logString += "\n\(file)"
                    if (file.pathExtension == "mp4"){
                        self.pickedVideoURL = file
                    }
                    if (file.pathExtension == "txt"){
                        self.pickedTextURL = file
                    }
                }
            }
            self.logTextView.text = logString
        }
    }


now i want to read the contents of the txt file... how?

Have you sample project?