Hello,
it will error:/storage/emulated/0/Documents/MyFolder/filename.docx: open failed: EEXIST (File exists)
Did you run your application on the android 10 or later?
For android 10, please add android:requestLegacyExternalStorage="true"
in <Application>
tag of AndroidManifest.xml
For Android 11 or later, this issue is related to Android 11 storage limitation, if you want to delete/create external file path, you need to request following permission and Manage all files on a storage device.
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
This permission needs request it. After that, you can execute the above code.
Best Regards,
Leon Lu
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.