Avatar of asbpenguinman
asbpenguinman
 asked on

Unzip file using 7-zip in C#

I am trying to use the 7-zip command line utility to unzip a file in a C# program.  I am having problems, however, getting it to unzip.
public static void Unzip(DirectoryInfo DirecInfo)
{
   if (DirectInfo.Exists)
   {
       foreach (FileInfo fileInfo in DirecInfo.GetFiles("*.zip"))
       {
           Process process = new Process();
           process.StartInfo.FileName = @"C:\Program Files\7-zip\7z.exe";
           process.StartInfo.Arguments = @" e C:\Directory\" + fileInfo.Name + @" -o C:\Directory";
           process.Start();
       }
   }
}

Open in new window

System UtilitiesC#

Avatar of undefined
Last Comment
Jaime Olivares

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
zveljkovic

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
abel

and it's probably a good idea to escape your backslashes :)
zveljkovic

no need because of @ prefix
abel

oops, you're right :P
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
asbpenguinman

ASKER
It was the space between the switch and the path that was the issue.  Thanks for the help.
Jaime Olivares

have a look to this article:
http://www.codeproject.com/KB/DLL/cs_interface_7zip.aspx

You will gain more control over 7zip working with the dll, than invoking the .exe