title: SharpCompress unpacking locks files
body: <p>Im trying to make a process where I unpack a set of rar-files using SharpCompress and then delete them.</p>
  
  <p>I first have a foreach loop which loops over the different set of files to be unpacked like this:</p>
  
  <pre><code>foreach (var package in extractionPackages.Where(package =&gt; Extractor.ExtractToFolder(package, destinationFolder)))
          {
              FileHelper.DeleteExtractionFiles(package);
          }
  </code></pre>
  
  <p>The extraction process is taken straight of the SharpCompress Tests code and goes like this:</p>
  
  <pre><code>public static bool ExtractToFolder(ExtractionPackage extractionPackage, string extractionPath)
      {
          var fullExtractionPath = Path.Combine(extractionPath, extractionPackage.FolderName);
          try
          {
              using (var reader = RarReader.Open(extractionPackage.ExtractionFiles.Select(p =&gt; File.OpenRead(p.FullPath))))
              {
                  while (reader.MoveToNextEntry())
                  {
                      reader.WriteEntryToDirectory(fullExtractionPath, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite);
                  }
  
              }
  
              return true;
          }
          catch (Exception)
          {
              return false;
          }
      }
  </code></pre>
  
  <p>As you can see in the first code block I then call to delete the files but there I recieve an error due to that the files are locked by another process:
  <strong>The process cannot access the file 'file.rar' because it is being used by another process.</strong></p>
  
  <p>If I try to put the deletion after the foreach-loop I am able to delete all but the last set of files if there are more than one. If it is just one the same issue occurs since the last set of files doesn't seems to be "unlocked".</p>
  
  <p>How can I structure the code so that the files is unlocked?</p>