我需要导入CSV/SQLite3文件到我的应用程序中,以恢复之前离线备份的设置。我使用Xamarin.Essentials.FilePicker
,它在Android上运行良好,但在iOS上尝试时,所有文件都是灰色的,我无法选择任何文件。
我在Android和iOS中使用以下文件类型:
var customFileType =
new Xamarin.Essentials.FilePickerFileType(new Dictionary<Xamarin.Essentials.DevicePlatform, IEnumerable<string>>
{
{ Xamarin.Essentials.DevicePlatform.iOS, new string[] {
"public.comma-separated-values-text",
"text/csv",
"comma-separated values",
"CSV document",
"csv",
"public.database",
"application/x-sqlite3",
"application/vnd.sqlite3",
"application/octet-stream",
} },
{ Xamarin.Essentials.DevicePlatform.Android, new string[] {
"text/csv",
"Comma-separated values",
"CSV document",
"application/x-sqlite3",
"application/vnd.sqlite3",
"application/octet-stream"
} },
}) ;
我也尝试过在iOS上添加text/plain
来选择CSV文件,但没有成功。另外,我也尝试过使用pdf
来选择PDF文件,但也没有成功。
我觉得我遗漏了一些与我正在放置的MIME
/UTType
无关的东西,但到目前为止我找不到任何这样的东西。
任何帮助都将不胜感激。
1条答案
按热度按时间bqf10yzr1#
this a weird issue that even I have faced and after scratching my head for a week I gave up(This was last year) I did not know this was still an issue in any case I would suggest you create a Bug in Essentials GitHub https://github.com/xamarin/Essentials/issues
And what you can do is for the time being use FilePicker Plugin(I am still using this): https://github.com/jfversluis/FilePicker-Plugin-for-Xamarin-and-Windows
And then use it like this :
This Library is marked deprecated by Gerald Versluis(Owner) but he will probably still accept PRs if needed in the future.
I hope this helps you out :)