0

I'm trying to find a way to read the contents/ file names of a zipped file, unzip the files and then create a text file with a list of all the files unzipped.

Most of that isn't a problem but reading and using the files in an archive is proving to be harder than it should be.

My current code is ...

var options = new Options();
            ICommandLineParser parser = new CommandLineParser();

            string strInput = "", strOutput = "", strExtract = "", strPassword = "";

            Console.WriteLine("parsing..");

            if (parser.ParseArguments(args, options))
            {
                Console.WriteLine("checking...");
                if (string.IsNullOrEmpty(options.InputFile))
                {
                    Console.WriteLine("input is empty");
                    Console.WriteLine(options.GetUsage()); 
                }

                strInput = options.InputFile;
                strOutput = options.OutputFile;
                strExtract = options.ExtractFormat;
                strPassword = options.Password;

                ProcessStartInfo p = new ProcessStartInfo();
                p.FileName = "7za.exe";

                Console.WriteLine("x " + "-" + strExtract + " -p" + strPassword + " " + strInput + " -o" + strOutput);
                p.Arguments = "x " + "-" + strExtract + " -p" + strPassword + " " + strInput + " -o" + strOutput;
                p.WindowStyle = ProcessWindowStyle.Hidden;

                Process x = Process.Start(p);
                x.WaitForExit();

I have found a few resources to help but none have worked so far. Resources found: http://pastebin.com/eTRE4TPP (I dont understand how they are using an undeclared variable, "l", but even changing that to "p" it doesnt work. http://www.dotnetperls.com/7-zip-examples (Command l looks like it could be used but I dont see how I can take the file names and store them)

Any help would be greatly appreciated.

Thanks

Lex Eichner
  • 1,056
  • 3
  • 10
  • 35
  • Why use an external process? Why not use SharpZip or DotNetZip? – Lloyd Jan 23 '13 at 11:32
  • Well I'm using 7-zip command line anyway (Due to specification and requirements) so I figured it must have a way to get and manipulate the files in an archive. If not I might have to use something else as well as 7-Zip. – Lex Eichner Jan 23 '13 at 11:37

1 Answers1

-1

What is it specifically that required you to use 7Zip? SharpZipLib may be able to do what you need.

Echilon
  • 10,064
  • 33
  • 131
  • 217