Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将文件导入到Isostore WP8_C#_Windows Phone 8 - Fatal编程技术网

C# 将文件导入到Isostore WP8

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

如何将歌曲从windows phone音乐库复制到应用程序的独立存储中

我需要这个转换成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/05 Beat It.mp3

到目前为止您尝试过什么吗?