public static void WriteZip(this PixelByte p, string zipfilename, string statusname = "000", bool append = false, CompressionLevel level = CompressionLevel.Fastest) { XML.PixelModelDependent.ModelDataXML buf = new XML.PixelModelDependent.ModelDataXML(); buf.Width = p.Width; buf.Height = p.Height; buf.FileName = new List <string> { $"^{statusname}.bin$" }; buf.FileSize = -1; buf.SetFileType(typeof(PixelByte)); //buf.SetFileType(p.GetType()); ZipArchiveMode mode = append ? ZipArchiveMode.Update : ZipArchiveMode.Create; using (var archive = ZipFile.Open(zipfilename, mode)) { using (var z = archive.CreateEntry($"PixelsModel\\{statusname}.model", level).Open()) { Pixels.IO.XMLSetter.Write <PixelModelDependent.ModelDataXML>(buf, z); } using (var z = archive.CreateEntry($"{statusname}.bin").Open()) { PixelStream.WriteBin(z, p); } } }
public static void WriteZipTxt(this PixelByte p, string zipfilename, string statusname = "000", bool append = false, CompressionLevel level = CompressionLevel.Fastest) { var sta = new StaPara(); sta.Width = p.Width; sta.Height = p.Height; sta.filename = statusname + ".txt"; sta.type = "txt"; ZipArchiveMode mode = append ? ZipArchiveMode.Update : ZipArchiveMode.Create; using (var archive = ZipFile.Open(zipfilename, mode)) { using (var z = archive.CreateEntry(statusname + ext_status, level).Open()) WriteStatus(z, sta); using (var z = archive.CreateEntry(sta.filename).Open()) PixelStream.WriteTxt(z, p); } }