简体   繁体   中英

How do I pick multiple files C# UWP?

I'm building a music app and need to allow the user to pick multiple files. I've tried the FileOpenPicker with PickMultipleFilesAsync() and it crashes with unexpected error.

Browsed the C# documentation with no success.

var openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
IReadOnlyList<StorageFile> files = await openPicker.PickMultipleFilesAsync(); // <- crashes here

Give it filetypefilter and try again

openpicker.FileTypeFilter.Add(".csv"); //add the type of of file you are going to select for example ".csv"

Otherwise from this small snippet everything seems fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM