Using ASP.NET Framework 4.7.1, I am trying to compress a file but Visual Studio is showing that ZipArchiveEntry does not contain the definition of ExtractToFile.
This is my code:
[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
if (file == null)
return View();
string path = Server.MapPath("~/App_Data/Uploads");
using(ZipArchive archive = new ZipArchive(file.InputStream))
{
foreach(ZipArchiveEntry entry in archive.Entries)
{
if(!string.IsNullOrEmpty(Path.GetExtension(entry.FullName)))
{
entry.ExtractToFile(Path.Combine(path, entry.FullName));
}
else
{
Directory.CreateDirectory(Path.Combine(path, entry.FullName));
}
}
}
}