尝试在Windows Phone app 8.1上使用多余的音乐文件夹,但获得以下异常:
System.Reflection.TargetInvocationException未处理消息:System.Windows.ni.dll中发生未处理的类型“System.Reflection.TargetInvocationException”异常附加信息:调用目标已抛出异常。
以下是代码:致电
try
{
GetFiles();
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
private async void GetFiles()
{
StorageFolder folder = KnownFolders.MusicLibrary;
IReadOnlyList<StorageFile> listOfFiles;
if (folder!=null)
{
listOfFiles =await folder.GetFilesAsync(); //this line casuing Debugger.break();
}
}
答案 0 :(得分:2)
答案 1 :(得分:0)
试试这个。
在 Windows 8.1 Universal
上完美运行 FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.MusicLibrary;
openPicker.FileTypeFilter.Add(".mp3");
openPicker.FileTypeFilter.Add(".wav");
openPicker.FileTypeFilter.Add(".mp4");
var file = await openPicker.PickSingleFileAsync();
try
{
var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read);
playbackElement3.SetSource(stream, file.ContentType);//Play Selected
playbackElement3.Play();
}
catch (Exception ex)
{
}
然后尝试从源
获取列表