I am working on a project where i update a ZipArchive and upload it back to server but I can only upload it using a stream.
public IActionResult DeleteZippedFile(string path)
{
//read the zip from stream
var zip = new ZipArchive(DownloadStream(Request.Cookies["OpenedZipPath"]), ZipArchiveMode.Update);
//make changes
zip.Entries.Where(x => x.Name == path).ToList()[0].Delete();
//i want to convert here <------
ftp.UploadStream(THESTREAMIWANT)
//and back to the zip
return RedirectToAction(nameof(OpenZip));
}
How can i save ZipArchive to a stream?
You can save ziparchiece using by ZipArchive.Save method
You created the
ZipArchive
using aStream
in the first place, so that is theStream
you should be using. If you need to reference that object again later then obviously you need to assign it to a variable. If you can’t use that particularStream
for whatever reason then copy the data from it to anotherStream
first and then create theZipArchive
from that.