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