1

我正在从(二进制)远程文件下载多个范围:

我创建一个请求并添加多个范围

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

如何在没有这些标题的情况下获取内容?

4

0 回答 0