我在微软找到了大量关于这个方法的信息,所以我知道这是可能的。我对用C#构建应用程序是全新的,所以我不太确定如何修复它。
我的代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Storage;
namespace MusicLibraryTest
{
public static class LibraryHelper
{
public static async void ChooseMusic()
{
//Music Library is opened on user's computer and displays all available mp3 files
var picker = new Windows.Storage.Pickers.FileOpenPicker
{
ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail,
SuggestedStartLocation =
Windows.Storage.Pickers.PickerLocationId.MusicLibrary
};
picker.FileTypeFilter.Add(".mp3");
//File is copied to local folder for use in music library
var file = picker.PickSingleFileAsync();
if (file != null)
{
await file.CopyAsync(ApplicationData.Current.LocalFolder);
}
}