你怎么一个文件夹添加到同一个ICSharpCode.SharpZipLib zip压缩包 [英] How do you add a folder to a zip archive with ICSharpCode.SharpZipLib
本文介绍了你怎么一个文件夹添加到同一个ICSharpCode.SharpZipLib zip压缩包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要创造我创建了以编程方式使用 ICSharpCode.SharZipLib.Zip
zip文件里面两个文件夹。我想:
I have to create two folders inside of a zip file that I create programmatically using ICSharpCode.SharZipLib.Zip
. I want to:
private void AddToZipStream(byte[] inputStream, ZipOutputStream zipStream, string fileName, string fileExtension)
{
var courseName = RemoveSpecialCharacters(fileName);
var m_Bytes = inputStream;
if ((m_Bytes != null) && (zipStream != null))
{
var newEntry = new ZipEntry(ZipEntry.CleanName(string.Concat(courseName, fileExtension)));
newEntry.DateTime = DateTime.Now;
newEntry.Size = m_Bytes.Length;
zipStream.PutNextEntry(newEntry);
zipStream.Write(m_Bytes, 0, m_Bytes.Length);
zipStream.CloseEntry();
zipStream.UseZip64 = UseZip64.Off;
}
}
如何创建使用目录的ZipEntry
,然后怎么办文件添加到位于邮编存档?
How do I create a directory using ZipEntry
and how do then add files to the directory located inside of the Zip archive?
推荐答案
我想通了:
- 您可以简单地做
新的ZipEntry(Folder1中/Archive.txt);
和新的ZipEntry(FOLDER2 / Archive2.txt);
- You can simply do
new ZipEntry("Folder1/Archive.txt");
andnew ZipEntry("Folder2/Archive2.txt");
这篇关于你怎么一个文件夹添加到同一个ICSharpCode.SharpZipLib zip压缩包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文