如何将歌曲从Windows手机音乐库复制到应用程序的独立存储空间?
我需要将每首歌转换为wav文件格式。
编辑1:我试过这个
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文件夹中导入所有文件,而不提供任何路径,例如"Music/05 Beat It.mp3"