using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MBIRevitBase.Tools
{
public static class ZipUtils
{
///
/// 压缩zip字符串流
///
///
///
///
public static Stream ZipString(string data,string fileName)
{
MemoryStream zipStream = new MemoryStream();
using (ZipArchive zipArchive = new ZipArchive(zipStream, ZipArchiveMode.Create, true))
{
ZipArchiveEntry entry = zipArchive.CreateEntry(fileName);
using (StreamWriter writer = new StreamWriter(entry.Open()))
{
writer.Write(data);
}
//zipArchive释放才会写入相关流
}
zipStream.Seek(0, SeekOrigin.Begin);
return zipStream;
}
}
}