c# - 如何选择多个文件 C# UWP?
问题描述
我正在构建一个音乐应用程序,需要允许用户选择多个文件。我已经使用 PickMultipleFilesAsync() 尝试了 FileOpenPicker,但它因意外错误而崩溃。
浏览 C# 文档没有成功。
var openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
IReadOnlyList<StorageFile> files = await openPicker.PickMultipleFilesAsync(); // <- crashes here
解决方案
给它 filetypefilter 然后再试一次
openpicker.FileTypeFilter.Add(".csv"); //add the type of of file you are going to select for example ".csv"
否则,从这个小片段来看,一切似乎都很好。
推荐阅读
- swift - 按钮最初在工具栏中显示为灰色
- html - 为什么我的引导 v5 卡在垂直窗口调整大小时移动?
- google-sheets - 反向百分比公式
- python - 正则表达式搜索熊猫数据框中的整列
- javascript - Webpack 5 - 来自 node_modules 的安静警告?
- reactjs - 从 inputComponent 捕获 onChange 事件传递给 OutlinedInput,Material UI
- python - 线程内的异步函数
- python - 使用 Libvirt Python createXMLFrom 克隆卷导致读取数据时文件结束:输入/输出错误
- mongodb - 更改对象数组中对象中的字段
- json - 通过 Codable 将 JSON 解析为数组