C# 压缩文件 的创建

using System;
using System.IO.Compression;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string path="D:\20170605.txt" ;
using (ZipArchive newFile = ZipFile.Open(path, ZipArchiveMode.Create))
{
ZipArchiveEntry entry = newFile.CreateEntry("zipDemo.txt", CompressionLevel.Optimal);
using (var entryStream = entry.Open())
{
using (StreamWriter sw = new StreamWriter(entryStream))
{
sw.Write("123");
}
}
}
}
}
}

原文地址:https://www.cnblogs.com/c-x-a/p/6962758.html