我现在有一个需求,下载一个gzip压缩包,包中有几个rdlc文件,我现在需要把这几个文件通过流的方式传递给客户端,然后客户端接收流。
现在我有两个请教:
1、怎样把多个文件通过流返回给客户端?
2、客户端怎样接收流,然后把这个流分拆成文件保存至临时文件夹。
弄的有点一筹莫展,请教各位同仁帮帮我,不知道怎么弄了就这么多分了,真心求教!!

解决方案 »

  1.   

    string fileName = "aaa.txt";//客户端保存的文件名
    string filePath = Server.MapPath("DownLoad/aaa.txt");//路径
    //以字符流的形式下载文件
    FileStream fs = new FileStream(filePath, FileMode.Open);
    byte[] bytes = new byte[(int)fs.Length];
    fs.Read(bytes, 0, bytes.Length);
    fs.Close();
    Response.ContentType = "application/octet-stream";
    //通知浏览器下载文件而不是打开
    Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.Response.BinaryWrite(bytes);
    Response.Flush();
      

  2.   


    有多个文件哦。。是个压缩包。。
    可以尝试直接传一个压缩包,收到压缩包之后再去解压缩。
    string zipFilePath = "c:\\test.zip";

    // 引用ICSharpCode.SharpZipLib.Zip.dll
    using (ZipInputStream zis = new ZipInputStream(System.IO.File.OpenRead(zipFilePath))) {
    ZipEntry ze; while ((ze = zis.GetNextEntry()) != null) {
    string targetFullFilePath = Path.Combine("c:\\zips", ze.Name);
    FileStream streamWriter = System.IO.File.Create(targetFullFilePath);
    int size = 2048;
    byte[] data = new byte[2048];
    while (true) {
    size = zis.Read(data, 0, data.Length);
    if (size > 0) {
    streamWriter.Write(data, 0, size);
    }
    else {
    break;
    }
    }
    streamWriter.Close();
    }
    }
      

  3.   


    有多个文件哦。。是个压缩包。。
    可以尝试直接传一个压缩包,收到压缩包之后再去解压缩。
    string zipFilePath = "c:\\test.zip";

    // 引用ICSharpCode.SharpZipLib.Zip.dll
    using (ZipInputStream zis = new ZipInputStream(System.IO.File.OpenRead(zipFilePath))) {
    ZipEntry ze; while ((ze = zis.GetNextEntry()) != null) {
    string targetFullFilePath = Path.Combine("c:\\zips", ze.Name);
    FileStream streamWriter = System.IO.File.Create(targetFullFilePath);
    int size = 2048;
    byte[] data = new byte[2048];
    while (true) {
    size = zis.Read(data, 0, data.Length);
    if (size > 0) {
    streamWriter.Write(data, 0, size);
    }
    else {
    break;
    }
    }
    streamWriter.Close();
    }
    }
    可是我压缩包里面有两个文件的流,我怎么把这两个文件的流分别识别出来呢?
      

  4.   

    asp.net传递压缩包,然后还要保存到制定目录?你这打算用什么插件?activeX还是啥?