public CreateEntry ( string entryName, CompressionLevel compressionLevel ) : |
||
entryName | string | A path relative to the root of the archive, indicating the name of the entry to be created. |
compressionLevel | CompressionLevel | The level of the compression (speed/memory vs. compressed size trade-off). |
return |
public ZipArchiveEntry CreateEntry(string entryName, CompressionLevel compressionLevel)
{
Contract.Ensures(Contract.Result<ZipArchiveEntry>() != null);
Contract.EndContractBlock();
return DoCreateEntry(entryName, compressionLevel);
}
ZipArchive::CreateEntry ( string entryName ) : System.IO.Compression.ZipArchiveEntry | |
ZipArchive::CreateEntry ( string entryName, System compressionLevel ) : System.IO.Compression.ZipArchiveEntry | |
ZipArchive::CreateEntry ( string entryName ) : |
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); }