I had the same problem and solved it by calling 7-zip executable through cmd shell from C# code, as follows,
string zipped_path = "xxx.7z";
string unzipped_path = "yyy";
string arguments = "e " + zipped_path + " -o" + unzipped_path;
System.Diagnostics.Process process
= Launch_in_Shell("C:\\Program Files (x86)\\7-Zip\\","7z.exe", arguments);
if (!(process.ExitCode == 0))
throw new Exception("Unable to decompress file: " + zipped_path);
And where Launch_in_Shell(...)
is defined as,
public static System.Diagnostics.Process Launch_in_Shell(string WorkingDirectory,
string FileName,
string Arguments)
{
System.Diagnostics.ProcessStartInfo processInfo
= new System.Diagnostics.ProcessStartInfo();
processInfo.WorkingDirectory = WorkingDirectory;
processInfo.FileName = FileName;
processInfo.Arguments = Arguments;
processInfo.UseShellExecute = true;
System.Diagnostics.Process process
= System.Diagnostics.Process.Start(processInfo);
return process;
}
Drawbacks: You need to have 7zip installed in your machine and I only tried it with ".7z" files. Hope this helps.