c# - Does CopyTo store the whole thing in memory? -
i have following code snippet, designed add files .zip file, while @ same time calculating sha1 checksum.
however, it's running out of memory on large files.
which part of causing whole file in memory? surely should streamed?
using (ziparchive archive = zipfile.open(buildfile, ziparchivemode.update)) { foreach (var filename in namelist) { ziparchiveentry entry = archive.createentry(source.filename); using (stream zipdata = entry.open()) using (sha1managed shaforfile = new sha1managed()) using (stream sourcefilestream = file.openread(filename)) using (stream sourcedata = new cryptostream(sourcefilestream, shaforfile, cryptostreammode.read)) { sourcedata.copyto(zipdata); print filename + ':' + shaforfile.hash; } } }
(copied comment - answers question)
the problem ziparchivemode.update, can require significant alterations file on disk. can ever directly stream disk when use ziparchivemode.create
Comments
Post a Comment