System.IO.Compression.ZipArchive.CreateEntry C# (CSharp) Метод

CreateEntry() публичный Метод

public CreateEntry ( string entryName ) : System.IO.Compression.ZipArchiveEntry
entryName string
Результат System.IO.Compression.ZipArchiveEntry
        public System.IO.Compression.ZipArchiveEntry CreateEntry(string entryName) { throw null; }
        public System.IO.Compression.ZipArchiveEntry CreateEntry(string entryName, System.IO.Compression.CompressionLevel compressionLevel) { throw null; }

Same methods

ZipArchive::CreateEntry ( string entryName, System compressionLevel ) : System.IO.Compression.ZipArchiveEntry
ZipArchive::CreateEntry ( string entryName ) : ZipArchiveEntry
ZipArchive::CreateEntry ( string entryName, CompressionLevel compressionLevel ) : ZipArchiveEntry

Usage Example

        public async Task <MemoryStream> GenerateZip(string report, string log)
        {
            using var ms      = new MemoryStream();
            using var archive =
                      new System.IO.Compression.ZipArchive(ms, ZipArchiveMode.Create, true);
            byte[] reportBytes = Encoding.ASCII.GetBytes(report);
            byte[] logBytes    = Encoding.ASCII.GetBytes(log);

            var zipEntry = archive.CreateEntry("Report.trx",
                                               CompressionLevel.Fastest);

            using (var zipStream = zipEntry.Open())
            {
                await zipStream.WriteAsync(reportBytes, 0, reportBytes.Length).ConfigureAwait(false);
            }

            var zipEntry2 = archive.CreateEntry("log.txt",
                                                CompressionLevel.Fastest);

            using (var zipStream = zipEntry2.Open())
            {
                await zipStream.WriteAsync(logBytes, 0, logBytes.Length).ConfigureAwait(false);
            }
            return(ms);
        }
All Usage Examples Of System.IO.Compression.ZipArchive::CreateEntry