我想創建一個zip文件,其中包含zip文件。我正在使用ICSharpCode.SharpZipLib(由於項目限制,必須使用它)。這工作正常,如果我只有1個字節[]數組..但它不適用於字節[]的列表。創建多字節[]陣列/文件的zip文件
foreach (byte[] internalZipFile in zipFiles)
{
// Source : internal zip file
MemoryStream inputMemoryStream = new MemoryStream(internalZipFile);
ZipEntry newZipEntry = new ZipEntry("AdManifest-" + i.ToString() + ".zip");
newZipEntry.DateTime = DateTime.Now;
zipStream.PutNextEntry(newZipEntry);
StreamUtils.Copy(inputMemoryStream, zipStream, new byte[1024]);
zipStream.CloseEntry();
zipStream.IsStreamOwner = false; // to stop the close and underlying stream
zipStream.Close();
outputMemoryStream.Position = 0;
zipByteArray = outputMemoryStream.ToArray();
i++;
}
using (FileStream fileStream = new FileStream(@"c:\manifest.zip", FileMode.Create))
{
fileStream.Write(zipByteArray, 0, zipByteArray.Length);
}
有人能幫忙嗎?我錯過了什麼?
請仔細閱讀[提問]和闡述「不工作」。 – CodeCaster