我有两个 MemoryStream 实例。
如何将它们合并为一个实例?
好吧,现在我不能从一个 MemoryStream 复制到另一个。这是一个方法:
public static Stream ZipFiles(IEnumerable<FileToZip> filesToZip) {
ZipStorer storer = null;
MemoryStream result = null;
try {
MemoryStream memory = new MemoryStream(1024);
storer = ZipStorer.Create(memory, GetDateTimeInRuFormat());
foreach (var currentFilePath in filesToZip) {
string fileName = Path.GetFileName(currentFilePath.FullPath);
storer.AddFile(ZipStorer.Compression.Deflate, currentFilePath.FullPath, fileName,
GetDateTimeInRuFormat());
}
result = new MemoryStream((int) storer.ZipFileStream.Length);
storer.ZipFileStream.CopyTo(result); //Does not work!
//result's length will be zero
}
catch (Exception) {
}
finally {
if (storer != null)
storer.Close();
}
return result;
}