我如何从7z中仅检索一个特定文件,而不是解压缩并转储到文件夹?

问题描述 投票:0回答:1

当前,我正在使用7ZipCLI.7z文件夹解压缩到指定的文件夹destPath,如下所示:

private void ExtractFile(string archivePath, string destPath)
{
    string zpath = @"C:\Program Files\7-Zip\x64\7za.exe";
    try
    {
        ProcessStartInfo pro = new ProcessStartInfo();
        pro.WindowStyle = ProcessWindowStyle.Hidden;
        pro.FileName = zpath;
        pro.Arguments = string.Format("x \"{0}\" -y -o\"{1}\"", archivePath, destPath);
        Process x = Process.Start(pro);
        x.WaitForExit();
    }
    catch (System.Exception Ex)
    {
        Console.WriteLine("{0} Exception: ", Ex)
    }
} 

这需要很长时间,因为应用程序将文件夹解压缩,将其卸载到destPath中,然后在destPath中搜索指定的文件。我将如何查看.7z,找到指定的文件,然后仅将该文件复制到destPath?

c# asp.net-mvc archive 7zip
1个回答
0
投票

如果您想对档案做一些有趣的事情,我建议您使用一个库而不是滚动自己的流程执行解决方案。几乎每个任务都有NuGet软件包,这也不例外。

© www.soinside.com 2019 - 2024. All rights reserved.