问题
I have some troubles.
It's about this subject => System.UnauthorizedAccessException : Access to the path “/storage/[Name]/[nameFolder]/[fileName].txt is denied.
At System.IO.FileStream etc….
I know this subject is already here in SOF, but I can't find a solution for Xamarin.Android. It's the same for Xamarin.Uwp, no access right.
I can't write a file in the root path (from the USB Flash Drive path) =
/storage/[NameOfTheFlashDrive]
It's the same if I use the Android path =
content://com.android.externalstorage.documents/documents/[NameOfTheFlashDrive]
Same message > System.UnauthorizedAccessException Access to the path
I don't know how to proceed.
I have used =
File.WriteAllText(filePath, Data);
And I have the permissions to write file in external storage.
The only solution is to use Plugin.Essential
or PickerFile
and save manually in the correct path.
If someone have a idea to proceed with the right way.
Thank you. Zebiphire.
回答1:
I have some troubles. It's about this subject => System.UnauthorizedAccessException : Access to the path “/storage/[Name]/[nameFolder]/[fileName].txt is denied. At System.IO.FileStream etc….
According to your error message, I guess that you ma need to enbale permission in runtime.
You should enable READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions in Android and UWP.
来源:https://stackoverflow.com/questions/55127363/cant-write-file-in-usb-flash-drive-with-xamarin-android-uwp