我试图过滤掉所有的文件,其中不是图像,视频,音频,pdf和其他文档文件,如微软。
目前,我的代码中包含以下内容:
var allowedUTIs = new string[] {
UTType.Image,
UTType.PDF,
UTType.Video,
UTType.Audio,
UTType.Movie,
UTTYPE.Text,
"com.microsoft.word.doc",
"com.microsoft.excel.xls",
"com.microsoft.powerpoint.ppt",
"org.openxmlformats.wordprocessingml.document"
};主要关注的是自定义的类型。它是否涵盖了所有microsoft offices文件类型: doc、xls、ppt、docx等。
是否还有其他我没有介绍的文档类型,例如苹果的特定文档文件。
发布于 2017-03-23 15:31:05
var allowedUtis = new string[] {
UTType.UTF8PlainText,
UTType.PlainText,
UTType.RTF,
UTType.PNG,
UTType.Text,
UTType.PDF,
UTType.Image,
UTType.UTF16PlainText,
UTType.FileURL,
"com.microsoft.word.doc",
"org.openxmlformats.wordprocessingml.document",
"com.microsoft.powerpoint.ppt"
"org.openxmlformats.spreadsheetml.sheet",
"org.openxmlformats.presentationml.presentation",
"com.microsoft.excel.xls"
};这些是我的UTTypes
在这里,对于文档"com.microsoft.word.doc",对于文档"org.openxmlformats.wordprocessingml.document“等等。我已经对所有的文档进行了测试。
发布于 2021-01-12 21:00:11
或者您可以像这样使用
var fileTypes = new string[] {
"public.utf8-plain-text",
"public.plain-text",
"public.text",
"public.png",
"public.jpeg",
"com.microsoft.bmp",
"public.composite-content"
"com.adobe.pdf",
"public.image",
"public.file-url",
"com.microsoft.word.doc",
"org.openxmlformats.wordprocessingml.document",
"com.microsoft.powerpoint.ppt",
"org.openxmlformats.spreadsheetml.sheet",
"org.openxmlformats.presentationml.presentation",
"com.microsoft.excel.xls"
};编辑
使用Xamarin essentials
var customFileType = new FilePickerFileType(new Dictionary<DevicePlatform, IEnumerable<string>>
{
{
DevicePlatform.Android, fileTypes
},
{
DevicePlatform.iOS, fileTypes
}
});
var file = await FilePicker.PickAsync(new PickOptions
{
PickerTitle = "Please select a file",
FileTypes = customFileType,
});发布于 2019-08-07 19:05:13
允许视频,和音频文件也有一个选项,如果不添加,它会显示文件,但禁用你不能挑选。
var allowedUTIs = new string[]
{
UTType.UTF8PlainText,
UTType.PlainText,
UTType.RTF,
UTType.PNG,
UTType.Text,
UTType.PDF,
UTType.Image,
UTType.UTF16PlainText,
UTType.FileURL,
UTType.Spreadsheet,
UTType.MP3,
UTType.MPEG4,
UTType.MPEG4Audio,
UTType.WaveformAudio,
UTType.Audio,
UTType.Video,
UTType.GIF,
UTType.BMP,
"org.openxmlformats.wordprocessingml.document",
"com.microsoft.powerpoint.ppt",
"org.openxmlformats.spreadsheetml.sheet",
"org.openxmlformats.presentationml.presentation",
"com.microsoft.excel.xls",
"com.microsoft.waveform-audio",
"com.microsoft.windows-media-wmv",
"com.adobe.illustrator.ai-image"
};https://stackoverflow.com/questions/41797644
复制相似问题