1

Closed

RarArchive.Open(string) leaves Streams open

description

That's my code:

string source = @"d:\MyProjects\ConsoleApplication1\Data\0105-exchange-betta-3.rar"; string destination = @"d:\MyProjects\ConsoleApplication1\Data\Output";

RarArchive archive = RarArchive.Open(source);
foreach (RarArchiveEntry entry in archive.Entries)
{
            string path = Path.Combine(destination, Path.GetFileName(entry.FilePath));
            entry.ExtractToFile(path, true);
}

File.Delete(source);

The programm fails on last line: File.Delete(source); "The process can't get access to file..."

Is there a way to delete archive after unraring?
Closed Nov 30, 2013 at 7:38 AM by adamhathcock

comments

gera_b wrote Apr 1, 2013 at 6:31 AM

Still got this issue in 1.0.1 version.

adamhathcock wrote Apr 1, 2013 at 8:25 AM

Try sharpcompress

gera_b wrote Apr 1, 2013 at 3:34 PM

sharpcompress have same problem )))

adamhathcock wrote Apr 2, 2013 at 9:30 AM

You need to dispose the RarArchive object. Put it in a using block.

gera_b wrote Apr 2, 2013 at 2:30 PM

That works! Amazing, thank you, Adam!

Kiwifranky wrote Nov 29, 2013 at 7:25 PM

Am I missing something?

RarArchive doesn't implement iDisposable and cannot be put in a using block.

Please Help!