title: Cannot access a closed file in ASP.Net (saving files in zip file)
body: <p>I got this error "Cannot access a closed file" when I save more than one file in zip.
  This is the code. Error at <code>zip.Save(NewZipPath);</code></p>
  
  <pre><code>internal static string UpdateZipFile(string PdfPath, string ZipPath, 
                      string NewZipPath, string docPath)
  {
      try
      {
      using (ZipFile zip = ZipFile.Read(ZipPath))
      {
          FileStream fs = new FileStream(PdfPath, FileMode.Open, FileAccess.Read);
  
          DirectoryInfo Dir = new DirectoryInfo(docPath);
  
          FileInfo[] FileList = Dir.GetFiles("*.*", SearchOption.AllDirectories);
  
          foreach (FileInfo FI in FileList)
          {
          zip.AddEntry(FI.FullName, fs);
          }
  
          // Error at this line if more than one
          // files in above directory.
          zip.Save(NewZipPath);
  
          fs.Close();
          fs.Dispose();
  
          return "- ZIP Generated Successfully !";
      }
      }
      catch (Exception ex)
      {
      return ex.Message;
      }
  }
  </code></pre>
  
  <p>Full exception</p>
  
  <pre><code>System.ObjectDisposedException: Cannot access a closed file.
     at System.IO.__Error.FileNotOpen()
     at System.IO.FileStream.get_Length()
     at Ionic.Zip.ZipEntry.SetInputAndFigureFileLength(Stream&amp; input)
     at Ionic.Zip.ZipEntry._WriteEntryData(Stream s)
     at Ionic.Zip.ZipEntry._EmitOne(Stream outstream)
     at Ionic.Zip.ZipEntry.Write(Stream s)
     at Ionic.Zip.ZipFile.Save()
     at Ionic.Zip.ZipFile.Save(String fileName)
     at RideShare.Utility.UpdateZipFile(String PdfPath, 
  String ZipPath, String NewZipPath, String docPath) in 
  </code></pre>
  
  <p>Thanks.</p>