Good afternoon! I have a file that is saved in a database, and I need to zip that file, if I download it. How do I do it? Thank you very much for the support
Good afternoon! I have a file that is saved in a database, and I need to zip that file, if I download it. How do I do it? Thank you very much for the support
Starting with the .NET Framework 4.5 Beta , it is possible manipulate ZIP archives. Example based on on this : / p>
using System;
using System.IO;
using System.IO.Compression;
using System.IO.Compression.FileSystem;
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
using (FileStream zipToOpen = new FileStream(@"c:\users\exampleuser\Desktop\release.zip", FileMode.Create))
{
using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Create))
{
archive.CreateEntryFromFile(@"c:\users\exampleuser\Desktop\MeuArquivoACompactar.dat", "arquivo.dat");
}
}
}
}
}