C#中的7z压缩不会影响所有文件 [英] 7z compress in C# don't comproess all files
本文介绍了C#中的7z压缩不会影响所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在努力通过c#中的七个zip sharp来压缩文件。
我需要压缩具有不同缩减的文件(例如.txt,* .abc ,* .tff等。
流程没有例外,但结果是错误的。
在7z文件夹中只存在* .txt文件。 />
有没有人有这种消息?
我尝试了什么:
Hi,
I am working to compress files via seven zip sharp in c#.
I need to compress files with different extenuations (like .txt, *.abc, *.tff ,etc).
The flow work without exceptions, but the result is wrong.
In the 7z folder just the *.txt files exists.
Does anyone have a solation?
What I have tried:
var cmp = new SevenZipCompressor
{
ScanOnlyWritable = false,
CompressionMode = Directory.Exists(@"C:\Users\User\Desktop\Zip.7z") ? SevenZip.CompressionMode.Append : SevenZip.CompressionMode.Create,
};
cmp.CompressFiles(@"C:\Users\User\Desktop\Zip.7z", "c:\\aaa\\file.abc");//this file don't exist in the output folder
推荐答案
请看这里: Code 4 Freaks:使用C#代码中的7-Zip压缩文件 [ ^ ]它给出了与你的代码非常相似的示例代码,但它没有传递一个固定的字符串作为第一个参数。
Look here: Code 4 Freaks: Compress files using 7-Zip from C# code[^] it gives example code that is very similar to yours, but that doesn't pass a fixed string as the first parameter.
你遗漏了一些东西。为什么在文件上使用Directory.Exists
?我假设Zip.7z是你的案件中的文件。
这不正确。 Explorer仅将.ZIP文件视为文件夹,以方便用户。它们仍然是应用程序中的实际文件,而不是文件夹。
You're missing something. Why are you usingDirectory.Exists
on a file? I'm assuming "Zip.7z" is a file in your case.
That's not correct. Explorer treats .ZIP files as folders only for convenience to the user. They are still actual files, not folders, in applications.
这篇关于C#中的7z压缩不会影响所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文