(バイナリ) リモート ファイルから複数の範囲をダウンロードしています。
リクエストを作成し、複数の範囲を追加します
HttpWebRequest MyRequest = (HttpWebRequest)WebRequest.Create("http://.....");
MyRequest.AddRange(606665, 681711);
MyRequest.AddRange(813525, 913711);
次に、リクエストを実行してレスポンスを処理します
HttpWebResponse MyResponse = (HttpWebResponse)MyRequest.GetResponse();
using (Stream MyResponseStream = MyResponse.GetResponseStream())
{
// Open the destination file
using (FileStream MyFileStream = new FileStream(@"C:\files\tempfile", FileMode.OpenOrCreate, FileAccess.Write))
{
// Create a 4K buffer to chunk the file
byte[] MyBuffer = new byte[4096];
int BytesRead;
// Read the chunk of the web response into the buffer
while (0 < (BytesRead = MyResponseStream.Read(MyBuffer, 0, MyBuffer.Length)))
{
// Write the chunk from the buffer to the file
MyFileStream.Write(MyBuffer, 0, BytesRead);
}
}
}
さて、私の問題は次のとおりです。宛先ファイルには、最初と各チャンクの間にヘッダー情報が含まれています。
--4def9076831c13664
Content-type: text/plain
Content-range: bytes 606665-681711/57955496
これらのヘッダーなしでコンテンツを取得するにはどうすればよいですか?