Created
April 19, 2020 10:26
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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