问题描述
我主要为 Android 开发,所以我知道可以使用 Android.Content.Context.GetExternalFilesDir
在 Xamarin.Forms 中访问 Android 设备的外部存储.
I'm mainly developing for Android, so I know one can access the external storage of an Android device in Xamarin.Forms using Android.Content.Context.GetExternalFilesDir
.
我知道可以使用 Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
独立访问内部存储平台,但是否也可以对外部存储执行相同操作?
I know its possible to access the internal storage platform-independently using Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
, but is it also possible to do the same for external storage?
我知道用例可能非常有限,因为 iOS 无论如何都不允许对文件系统进行任何非越狱访问,但是写入外部文件系统而不必为它实现它不是仍然很好吗?每个平台?难道不能只写入根应用程序文件目录并让 OS API 处理其余部分吗?我很新,所以不要对这个愚蠢的问题笑得太多.
I know the use case might be prettty limited, as iOS doesn't allow any non-jailbreaked access to the file system anyway, but wouldn't it still be good to write to external file systems without having to implement it for each platform? Couldn't one just write to the root app files directory and let the OS API handle the rest? I'm pretty new so don't laugh too much at the stupid question.
非常感谢您的帮助.
推荐答案
Forms 没有提供访问外部存储的 api,我们必须在每个特定的平台上实现它,请查看 https://docs.microsoft.com/en-us/xamarin/android/平台/文件/external-storage?tabs=windows
Forms does not provide the api to access External storage , we have to implement it in each specific platform ,please check https://docs.microsoft.com/en-us/xamarin/android/platform/files/external-storage?tabs=windows
这篇关于是否可以在 Xamarin.Forms 中以独立于平台的代码访问外部存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!