Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Last active May 16, 2019 11:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unitycoder/edfc22570e93db61f83d582c98c4dff5 to your computer and use it in GitHub Desktop.
Save unitycoder/edfc22570e93db61f83d582c98c4dff5 to your computer and use it in GitHub Desktop.
Unity SharpCompress Test - Create Zip package from files in folder
// unity sharpcompress example : https://unitycoder.com/blog/2019/05/12/using-sharpcompress-in-unity/
// https://github.com/adamhathcock/sharpcompress
using SharpCompress.Archives;
using SharpCompress.Archives.Zip;
using System.IO;
using UnityEngine;
public class SharpCompressTest : MonoBehaviour
{
void Start()
{
// ZipArchive with Writing API Example: (creates zip file from source folder files)
using (var archive = ZipArchive.Create())
{
string sourceFolder = "d:/data/testzip";
archive.AddAllFromDirectory(sourceFolder);
string outputPath = "d:/data/test.zip";
using (FileStream fs = File.Create(outputPath))
{
archive.SaveTo(fs);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment