I have a folder containing a million zip files which I need to extract. Two ways I have tried:
Way 1: Use the 7-zip exe file and System.Diagnostic Process as follows
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = "7za.exe"
p.Arguments = "e " + sourceName; // sourceName is the name of the zip file
p.WindowStyle = ProcessWindowStyle.Hidden;
Process x = Process.Start(p);
x.WaitForExit();
Way 2: Use the 7z.dll and SevenZipExtractor as follows
SevenZipExtractor.SetLibraryPath(@"C:\Program Files\7-Zip\7z.dll");
SevenZipExtractor zipFile = new SevenZipExtractor("inv1_0.zip");
zipFile.ExtractArchive(@"c:\projects\extractor\extractor\bin\debug\inv1_0.dat");
Two things here:
a) Way 1 works perfectly fine. Way 2 doesn't work. Give the error "SevenZip.SevenZipArchiveException: Invalid archive: open/read error!". Can someone suggest why this could be happening when way 1 is giving the correct extracted file?
b) Since there are a million zip files, I am worried about using Way 1 : as in the Process. How expensive is to loop through a million zip files and use process for each one of them. I would really like to use Way 2 but for some reason it gives the exception.