Exemple #1
0
        public FileResult GetFiles(int Id)
        {
            var files = teamLeaderRepository.GetFilesByWorkId(Id);

            using (MemoryStream ms = new MemoryStream())
            {
                using (var archive = new ZipArchive(ms, ZipArchiveMode.Create, true))
                {
                    foreach (var file in files)
                    {
                        var entry = archive.CreateEntry(file.FileName, CompressionLevel.Fastest);
                        using (var zipStream = entry.Open())
                        {
                            zipStream.Write(file.FileBytes, 0, file.FileBytes.Length);
                        }
                    }
                }
                return(File(ms.ToArray(), "application/zip", "Archive.zip"));
            }
        }