public static async Task ExtractZipFile(string fileName, string extractPath)
{
await Task.Run(() =>
{
using (ZipArchive package = ZipFile.OpenRead(fileName))
{
foreach (var entry in package.Entries)
{
string fullPath = Path.Combine(extractPath, entry.FullName);
if(!Directory.Exists(Path.GetDirectoryName(fullPath))){
try
{
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
}catch (IOException){
}
}
if (String.IsNullOrEmpty(entry.Name))
{
Directory.CreateDirectory(fullPath);
}
else
{
try
{
entry.ExtractToFile(fullPath, true);
}
catch (IOException ex)
{
Console.WriteLine(ex);
}
}
}
}
});
}