Skip to content

Instantly share code, notes, and snippets.

@MorenoGentili
Created April 19, 2020 10:26
Show Gist options
  • Save MorenoGentili/30853f5ae8f3231445dac1433abd739e to your computer and use it in GitHub Desktop.
Save MorenoGentili/30853f5ae8f3231445dac1433abd739e to your computer and use it in GitHub Desktop.
Decompress a zip archive uploaded by the user in ASP.NET Core 3.x
using System.IO.Compression;
using Microsoft.AspNetCore.Http;
namespace DecompressDemo.Models.Services.Infrastructure
{
public class DocumentPersister
{
public void DecompressZipArchive(string directory, IFormFile formFile)
{
using Stream stream = formFile.OpenReadStream();
using ZipArchive archive = new ZipArchive(stream);
archive.ExtractToDirectory(directory);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment