C# 将文件导入到Isostore WP8
如何将歌曲从windows phone音乐库复制到应用程序的独立存储中 我需要这个转换成wav文件格式的每首歌曲 编辑1:我试过这个C# 将文件导入到Isostore WP8,c#,windows-phone-8,C#,Windows Phone 8,如何将歌曲从windows phone音乐库复制到应用程序的独立存储中 我需要这个转换成wav文件格式的每首歌曲 编辑1:我试过这个 private async void ImportMediaLibrary() { try { var sourceFile = await Package.Current.InstalledLocation .GetFileAsync("Music/05 Beat It.mp3"); Cop
private async void ImportMediaLibrary()
{
try
{
var sourceFile = await Package.Current.InstalledLocation
.GetFileAsync("Music/05 Beat It.mp3");
CopyFileIntoIsoStore(sourceFile);
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.Message+"\n"+e.StackTrace);
}
}
private async void CopyFileIntoIsoStore(StorageFile sourceFile)
{
using (var s = await sourceFile.OpenReadAsync())
using (var dr = new DataReader(s))
using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
using (var targetFile = isoStore.CreateFile(sourceFile.Name))
{
var data = new byte[s.Size];
await dr.LoadAsync((uint)s.Size);
dr.ReadBytes(data);
targetFile.Write(data, 0, data.Length);
}
}
但我有一个错误:
Value does not fall within the expected range.
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at StretchAndShift.MainPage.<ImportMediaLibrary>d__0.MoveNext()
但是文件在正确的位置。。。我想从“音乐”文件夹导入所有文件,但不提供任何路径,如Music/05 Beat It.mp3到目前为止您尝试过什么吗?