相关疑难解决方法(0)

以块的形式下载文件(Windows Phone)

在我的应用程序中,我可以从网上下载一些媒体文件.通常我使用WebClient.OpenReadCompleted方法下载,解密并将文件保存到IsolatedStorage.它运作良好,看起来像这样:

 private void downloadedSong_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e, SomeOtherValues someOtherValues) // delegate, uses additional values
        {
            // Some preparations

                try
                {
                   if (e.Result != null)
                   {
                    using (isolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication())
                    {
                        // working with the gained stream, decryption
                        // saving the decrypted file to isolatedStorage
                        isolatedStorageFileStream = new IsolatedStorageFileStream("SomeFileNameHere", FileMode.OpenOrCreate, isolatedStorageFile);
                        // and use it for MediaElement
                        mediaElement.SetSource(isolatedStorageFileStream);
                        mediaElement.Position = new TimeSpan(0);
                        mediaElement.MediaOpened += new RoutedEventHandler(mediaFile_MediaOpened);

                        // and some other work
                     }
                    }
                 }
                 catch(Exception ex) 
                 {
                  // try/catch …
Run Code Online (Sandbox Code Playgroud)

c# download chunking windows-phone-7

6
推荐指数
1
解决办法
2407
查看次数

标签 统计

c# ×1

chunking ×1

download ×1

windows-phone-7 ×1