Ejemplo n.º 1
0
        public byte[] ZipProject(int id)
        {
            var directory = "~/../../Uploads/Projects//" + this.db.Projects.FirstOrDefault(p => p.Id == id).RootFolderName;

            using (var memoryStream = new MemoryStream())
            {
                using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
                {
                    Zipper.ProcessDirectory(directory, archive);
                }
                return(memoryStream.ToArray());
            }
        }
Ejemplo n.º 2
0
        public byte[] ZipFolder(string id)
        {
            var directory = this.db.Folders.FirstOrDefault(f => f.Id.ToString() == id);

            if (directory == null)
            {
                return(null);
            }
            using (var memoryStream = new MemoryStream())
            {
                using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
                {
                    Zipper.ProcessDirectory(directory.Path, archive);
                }
                return(memoryStream.ToArray());
            }
        }