压缩文件

示例代码:

       string filepath = Server.MapPath("Textfile.txt");
        FileStream infile = File.OpenRead(filepath);
        byte[] buffer = new byte[infile.Length];
        infile.Read(buffer, 0, buffer.Length);
        infile.Close();
        FileStream outfile=File.Create(Path.ChangeExtension(filepath,"zip"));
        GZipStream gzipstream=new GZipStream(outfile,CompressionMode.Compress);
        gzipstream.Write(buffer,0,buffer.Length);
        gzipstream.Close();
      

posted @   IT苦行僧  阅读(153)  评论(0编辑  收藏  举报

喜欢请打赏

扫描二维码打赏

了解更多

点击右上角即可分享
微信分享提示