using System.Collections.Generic;
using System.IO.Compression;
public static void Main()
var a = "UEsDBBQAAAAIAAdTOU+ltVJMngAAAOAAAAAyAAAAaW1wb3J0YWNhby1wb3NpY2FvLVRpdFB1YmxpY29zX2V4ZW1wbG9fMTY3X0xvZy5jc3aFzrENgkAUANDexB1+qY3AKQX8iogkJCJCWODLnXgF981xTmRtZWlhwUCuoAOQOMBL3uf1bvSVMSVHuNfmQlgoM1CnepzP8kNW1kWyTUoUoedHnvCDCAI/Fps4EIi5GR+tZpAMR8utGgbqlXG8+tldXU+pNQpsqIOqSWFR3cg4LUmqJfDJ6o7c+LSawIx3Bm3ObHuS9G8SIma6n1x8AVBLAQIUABQAAAAIAAdTOU+ltVJMngAAAOAAAAAyAAAAAAAAAAAAAAAAAAAAAABpbXBvcnRhY2FvLXBvc2ljYW8tVGl0UHVibGljb3NfZXhlbXBsb18xNjdfTG9nLmNzdlBLBQYAAAAAAQABAGAAAADuAAAAAAA=";
Console.WriteLine(ZipUtils.Base64Decode(a));
public static class ZipUtils
public static byte[] ZipFiles(Dictionary<string, string> mapMonthToData)
using (var ms = new MemoryStream())
using (var zipArchive = new ZipArchive(ms, ZipArchiveMode.Create, true))
foreach (var attachment in mapMonthToData)
var entry = zipArchive.CreateEntry(attachment.Key);
using (var entryStream = entry.Open())
using (var streamWriter = new StreamWriter(entryStream, Encoding.UTF8))
streamWriter.Write(attachment.Value);
public static byte[] Zip(string textToZip, string fileName = null)
if (string.IsNullOrEmpty(fileName))
return ZipFiles(new Dictionary<string, string>
public static string Unzip(byte[] zippedBuffer)
using (var zippedStream = new MemoryStream(zippedBuffer))
using (var archive = new ZipArchive(zippedStream))
ZipArchiveEntry entry = null;
if (archive.Entries.Count > 0)
entry = archive.Entries[0];
using (var unzippedEntryStream = entry.Open())
using (var ms = new MemoryStream())
unzippedEntryStream.CopyTo(ms);
var unzippedArray = ms.ToArray();
return Encoding.UTF8.GetString(unzippedArray);
public static string Base64Encode(byte[] data)
string encodedData = Convert.ToBase64String(data);
throw new Exception("Base64Encode()" + ex.ToString());
public static byte[] Base64Decode(string data)
byte[] todecode_byte = Convert.FromBase64String(data);
throw new Exception("Base64Decode()" + ex.ToString());