Invalid zip file after creating it with System.IO.Compression

You need to get the MemoryStream buffer via ToArray after the ZipArchive object gets disposed. Otherwise you end up with corrupted archive.

And please note that I have changed the parameters of ZipArchive constructor to keep it open when adding entries.

There is some checksumming going on when the ZipArchive is beeing disposed so if you read the MemoryStream before, it is still incomplete.

    private FileResult CreateZip(IEnumerable<FileContentResult> files)
    {
        byte[] retVal = null;

        if (files.Any())
        {
            using (MemoryStream zipStream = new MemoryStream())
            {
                using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create, true))
                {
                    foreach (var f in files)
                    {
                        var entry = archive.CreateEntry(f.FileDownloadName, CompressionLevel.Fastest);
                        using (BinaryWriter writer = new BinaryWriter(entry.Open()))
                        {                                   
                            writer.Write(f.FileContents, 0, f.FileContents.Length);
                            writer.Close();
                        }
                    }

                    zipStream.Position = 0;
                }
                retVal = zipStream.ToArray();
            }
        }

        return File(retVal, MediaTypeNames.Application.Zip, "horta.zip");
    }

Just return the stream...

private ActionResult CreateZip(IEnumerable files)
{
    if (files.Any())
    {
        MemoryStream zipStream = new MemoryStream();
        using (ZipArchive archive = new ZipArchive(zipStream, ZipArchiveMode.Create, false))
        {
            foreach (var f in files)
            {
               var entry = archive.CreateEntry(f.FileDownloadName, CompressionLevel.Fastest);
               using (var entryStream = entry.Open())
               {
                   entryStream.Write(f.FileContents, 0, f.FileContents.Length);
                   entryStream.Close();
               }
           }

        }

        zipStream.Position = 0;
        return File(zipStream, MediaTypeNames.Application.Zip, "horta.zip");
    }

    return new EmptyResult();
}