-1

这是我的代码,我试图从 url 制作一个流,我想将文件切成 6 块并下载,因为我想将流连接到文件信息,但我遇到了一些错误。谢谢

FileInfo fs;
DateTime startTime = DateTime.UtcNow;
WebRequest request = WebRequest.Create("http://tegos.ru/new/mp3_full/David_Guetta_feat_Ne-Yo_and_Akon_-_Play_Hard.mp3");
WebResponse response = request.GetResponse();
using (Stream responseStream = response.GetResponseStream()) 
using (Stream fileStream = fs new FileInfo("")))

错误“System.IO.FileInfo”是“类型”,但用作“变量”

4

1 回答 1

0

假设您要将 HTTP 响应中的流复制到文件中:

using (Stream output = File.OpenWrite("pah_to_file"))
{
    using (Stream input = http.Response.GetResponseStream())
    {
        byte[] buffer = new byte[2048]; // some buffer
        int bytesRead;
        while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0)
        {
            output.Write(buffer, 0, bytesRead);
        }
    }
}

如果不是这种情况,请重新表述您的问题。

于 2013-04-26T09:25:03.457 回答