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");
}
}
}
}
}
}

posted @ 2017-06-08 14:50  公众号python学习开发  阅读(143)  评论(0编辑  收藏  举报