buzzzzjay
buzzzzjay

Reputation: 1150

C# Using 7zip to get list of files in an archive?

I am using 7zip http://www.7-zip.org/download.html in a C# program to unzip files using the code below.

Process t = new Process();
t.StartInfo.FileName = "7za.exe";
t.StartInfo.Arguments = "e " + filePath[i] + " -y -o" + directory[3];
t.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
t.EnableRaisingEvents = true;
t.StartInfo.UseShellExecute = false;
l.StartInfo.RedirectStandardOutput = true;
t.Start();
Console.WriteLine(l.StandardOutput.ReadToEnd());
t.WaitForExit();

I have found searching through the 7zip help that it is possible to use l instead of e (line 3) to list the contents of the archive, but I can't figure out how to get the file names of the files contained in the archive. Any ideas? Thanks!

Upvotes: 4

Views: 4580

Answers (1)

SLaks
SLaks

Reputation: 887375

You should use the 7zip SDK or SevenZipSharp.

To answer your question, set RedirectStandardOutput to true, then read t.Output.

Upvotes: 6

Related Questions