Skip to content

Instantly share code, notes, and snippets.

@snmslavk
Created April 14, 2016 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snmslavk/98a86350541cb6fbfd6bcd1a8f766327 to your computer and use it in GitHub Desktop.
Save snmslavk/98a86350541cb6fbfd6bcd1a8f766327 to your computer and use it in GitHub Desktop.
Create zip
using System.Collections.Generic;
using System.IO;
namespace ZipLib
{
public class ZipFuncs
{
public static byte[] CreateZipArhive(List<string> _pathin)
{
if ((_pathin ?? new List<string>()).Count > 0)
using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
{
_pathin.ForEach(_path =>
{
zip.AddFile(_path,@"\");
});
using (var ms = new MemoryStream())
{
zip.Save(ms);
return ms.ToArray();
}
}
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment