【发布时间】:2020-05-15 21:59:37
【问题描述】:
我正在使用此代码压缩文件夹:
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = @"C:\Program Files\7-Zip\7z.exe";
p.Arguments = "a -t7z \"" + targetName + "\" \"" + item.ToString() + "\" -mx=9";
p.WindowStyle = ProcessWindowStyle.Minimized;
Process x = Process.Start(p);
x.WaitForExit();
Directory.Delete(dirPath + "\\" + item.Name, true);
当应用程序编译时,我得到这个输出:
7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21
Open archive: C:\a\b\folders\compress.7z
--
Path = C:\a\b\folders\compress.7z
Type = 7z
Physical Size = 881619
Headers Size = 273
Method = LZMA2:23
Solid = +
Blocks = 1
Scanning the drive:
1 folder, 2 files, 8258668 bytes (8066 KiB)
Updating archive: C:\a\b\folders\compress.7z
Add new data to archive: 1 folder, 2 files, 8258668 bytes (8066 KiB)
60% U Folder\thisisatext.txt
但我只想要这个:60% U Folder\thisisatext.txt
我能以某种方式做到这一点吗?感谢您的任何回复。
【问题讨论】:
-
提示:在构建路径时考虑
Path.Combine而不是连接字符串 - 它可以处理很多边缘情况并放入正确的斜杠等。
标签: c# compression output 7zip