我正在尝试过滤掉所有不是图片,视频,音频,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 office文件类型:doc,xls,ppt,docx等......
我是否还有其他未涵盖的文件类型,例如apple的特定文档文件。
答案 0 :(得分:2)
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,
在此,对于doc“com.microsoft.word.doc”,对于docx“org.openxmlformats.wordprocessingml.document”等。我已经对所有文件进行了测试。
答案 1 :(得分:1)
或者你可以这样使用
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"
};
答案 2 :(得分:0)
要允许视频和音频文件,也有一个选项,如果未添加,它将显示文件但已禁用,您不能选择它。
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"
};