简体   繁体   English

使用7-zip阅读档案

[英]Reading archive using 7-zip

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) 找到的资源: http : //pastebin.com/eTRE4TPP (我不明白他们如何使用未声明的变量“ l”,但即使将其更改为“ p”也无法使用。http://www.dotnetperls.com/ 7-zip-examples (命令l看起来可以使用,但是我看不到如何获取文件名并存储它们)

Any help would be greatly appreciated. 任何帮助将不胜感激。

Thanks 谢谢

What is it specifically that required you to use 7Zip? 要求您使用7Zip的具体含义是什么? SharpZipLib may be able to do what you need. SharpZipLib也许可以满足您的需求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM