私はC#でダウンロードマネージャーを作成しています。現在、URLを指定して、URLからファイルをセグメントでダウンロードするダウンロードコンポーネントを設計しています。
以下に示すように、現在、各チャンクに I/O ストリームを使用しています。
MyChunks.InputStream = rs ;
//rs is obtained by using GetResponse() from FtpWebRequest or HttpWebRequest
MyChunks.OutputStream = fs ; //fs is FileStream for writing on local file
chunksize = MyChunks.InputStream.Read(buffer, 0, bufferSize);
MyChunks.OutputStream.Write(buffer, 0, (int)chunksize);
私が分析した他のメソッドについては、`WebClient.DownloadDataAsync` メソッドも使用できることがわかりました。
ただし、複数のスレッドでダウンロードされたデータのチャンクを利用してダウンロードを高速化することはできません。さらに、上記のコードは正常に動作しています。
私の質問は次のとおりです。
チャンクをダウンロードする他の方法はありますか、または上記のコードで問題ありませんか?
また、ダウンロードしたオーディオ (mp3)/ビデオ ファイルを再生したいのですが、同じことを行う方法を提案できますか?