How to zip a file in .NET
It easy to do by use System.IO.Compression.ZipFile using System.IO.Compression; string guid = Guid.NewGuid().ToString(); string fileName = guid + ".json"; using (ZipArchive archive = ZipFile.Open(zipPath, ZipArchiveMode.Create)) { archive.CreateEntryFromFile(fileName, Path.GetFileName(fileName)); } Cheers !
It easy to do by use System.IO.Compression.ZipFile
using System.IO.Compression;
string guid = Guid.NewGuid().ToString();
string fileName = guid + ".json";
using (ZipArchive archive = ZipFile.Open(zipPath, ZipArchiveMode.Create))
{
archive.CreateEntryFromFile(fileName, Path.GetFileName(fileName));
}
Cheers !