Problems with releasing an object and closing a spreadsheet?
<p>I am using EPPlus to open a spreadsheet and then populate it with pictures and information.
When i try to delete a folder containing all the pictures i used to populate my spreadsheet i get the error that this file is in use with another application. What would be the correct way to release the objects used and close the spreadsheet?</p>

<pre><code>using (var package = new ExcelPackage(existingFile))
     {
        ExcelWorkbook workBook = package.Workbook;
        if (workBook != null)
        {
          if (workBook.Worksheets.Count &gt; 0)
            {
              int i = 0;
              foreach(ExcelWorksheet worksheet in workBook.Worksheets)
              {
                xlWorkSeet1[i] = worksheet;
                i = i + 1;
              }

            }
        }

           //More code ...

           FileStream aFile = new FileStream(tempFolderPathAlt + saveas + ".xls",    FileMode.Create);
           byte[] byData = package.GetAsByteArray();
           aFile.Seek(0, SeekOrigin.Begin);
           aFile.Write(byData, 0, byData.Length);
           aFile.Close();

            xlWorkSeet1 = null;
            workBook = null;


      }//End using

     String P = Path.Combine(tempFolderPathAlt, "ExtractedFiles");
     bool directoryExists = Directory.Exists(P);
     if (directoryExists)
     Directory.Delete(P, true); // deletes sub-directories
</code></pre>

<p>The error i get is when it is trying to delete a photo i added to my spreadsheet.</p>

<p><img src="http://i.stack.imgur.com/IP8Z2.png" alt="enter image description here"></p>
