Android.OS.Environment.ExternalStorageDirectory.AbsolutePaht is obsolete
how to get it now?
Android.OS.Environment.ExternalStorageDirectory.AbsolutePaht is obsolete
how to get it now?
Hello,
Welcome to our Microsoft Q&A platform!
You can use Application.Context.GetExternalFilesDir();, Application.Context.GetExternalCacheDirs(); Application.Context.GetExternalMediaDirs(); But three method store file in your application folder /storage/emulated/0/Android/data/com.companyname.xxx/cache , it will not store file to the external folder path.
Here is similar thread:
https://stackoverflow.com/a/57116787/10627299
Note: If your targetSdkVersion is below 30 and want to store file to external public folder, using android:requestLegacyExternalStorage="true" in the <application> element of the manifest. This is not a long-term solution, as your targetSdkVersion will need to be 30 or higher, due to the Android 11’s limitation of storage, we have to store file to the application folder /storage/emulated/0/Android/data/com.companyname.xxx/, so store the file to internal path with var InternalPath= Android.App.Application.Context.GetExternalFilesDir("").AbsolutePath; is a suitable way.
`
Best Regards,
Leon Lu
If the response is helpful, please click "Accept Answer" and upvote it.
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.
If you want to get Image from DCIM, you can use ContentResolver to get it .please refer to this thread: https://stackoverflow.com/a/57649669/10627299
8 people are following this question.