0

I am using following code to perform download in MVC:

CONTROLLER:

 public ActionResult Download(string SysID)
    {
        try
        {

            byte[] fileData = Get Data in Byte array;
            if (fileData != null)
            {
                string fileName = "Mytest.bin";
                return File(fileData, "application/octet-stream", fileName);
            }
            else
                return null;
        }

        catch (Exception ex)
        {
            throw ex;
        }
    }

Everything is working fine using above code. I am able to generate .bin file and successfully downloaded.

Problem:

How i can wrap this in zip file using SharpZipLib? I am restricted to use SharpZipLib. Reason behind this is i need to send this file to other systems where we are already using SharpZipLib to unzip files.

Please let me know if more info required, i will try my best to provide more information.

Thanks in advance.

Sunny
  • 3,185
  • 8
  • 34
  • 66
  • 1
    I haven't used SharpZipLib in a while, but IIRC they have decent documentation, and you should be able to find how to use the API. – Tsahi Asher Mar 02 '17 at 07:29
  • I am restricted to use SharpZipLib. Reason behind this is i need to send this file to other systems where we are already using SharpZipLib to unzip files. – Sunny Mar 02 '17 at 07:31
  • 1
    Didn't know that you need to zip something specifically with SharpZipLib to be able to unzip that on other system with SharpZipLib. – Evk Mar 02 '17 at 08:33

1 Answers1

0

Refer below link Create a Zip as a browser download attachment in IIS section for creating and downloading the file as zip to browser. Hope this helps.

https://github.com/icsharpcode/SharpZipLib/wiki/Zip-Samples#create-a-zip-as-a-browser-download-attachment-in-iis

Pradeep
  • 4,612
  • 10
  • 38
  • 50