title: PDF File Zip in Memory Stream Showing not supported file or damaged My Code attached
body: <p>I have pdf file in directory that can be open successfully. I am actually changing into byte[] and zip it in memory stream and return it.</p>
  
  <p>I got all files as zipped but when i am opening files getting error </p>
  
  <blockquote>
    <p>"File can not be open either it has not supported type or file is damage"</p>
  </blockquote>
  
  <p>I am changing pdf file to byte[],</p>
  
  <pre><code>ArrayList PDFbyteList = new ArrayList();
  
  byte[] bytes = System.IO.File.ReadAllBytes(@"C:\Windows\SysWOW64\config\systemprofile\Desktop\" + PdfFile);
  PDFbyteList.Add(bytes);
  </code></pre>
  
  <p>Then I change it to zip using memory stream,</p>
  
  <pre><code>public FileResult DownloadMultiplePDFFiles(List&lt;FileResult&gt; list)
          {
              int count = list.Count();
              byte[] file1;
              using (MemoryStream ms = new MemoryStream())
              {
                  using (var archive = new ZipArchive(ms, ZipArchiveMode.Create, true))
                  {
                      for (var i = 0; i &lt; count; i++)
                      {
                          file1 = ObjectToByteArray(PDFbyteList[i]);
                          string name = list[i].FileDownloadName.Split('.')[0];
                          name = name + ".pdf";
                          var zipArchiveEntry = archive.CreateEntry(name, CompressionLevel.Fastest);
                          using (var zipStream = zipArchiveEntry.Open()) zipStream.Write(file1, 0, file1.Length);
                          file1 = null;
                      }
                  }
                  //return File(ms.ToArray(), "application/zip", "Reports.zip");
                  return File(ms.ToArray(), "application/octet-stream", "Reports.zip");
              }
          }
  </code></pre>
  
  <p>Parameter list having content-type , file name and bytes. I am taking only file name from here and bytes from array list. Well content type in parameter list is "application/octet-stream".</p>
  
  <p>I tried with "application/octet-stream" as well as "application/zip" having same error.</p>
  
  <p>Hopes for your help</p>