Compact a file saved in Bank

1

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

    
asked by anonymous 05.06.2018 / 21:13

1 answer

0

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");
                }
            }
        }
    }
}
    
05.06.2018 / 22:08