Decompressing password-protected ZIP files with .NET 4.5

前端 未结 7 817
遇见更好的自我
遇见更好的自我 2020-12-03 09:39

Microsoft introduces improvements for ZIP file handling in .NET 4.5 in the System.IO.Compression namespace. Namely the classes ZipArchive and ZipFile. However, I have not y

7条回答
  •  借酒劲吻你
    2020-12-03 10:10

    I found the way is very simple to unzip in c#
    Install PM (you can find new version if available!)

    Install-Package Ionic.Zip -Version 1.9.1.8
    

    Code C#

    string zipFile = @"C:\Users\Fesslersoft\Desktop\ZipTest\Test.zip";
    string targetDirectory = @"C:\Users\Fesslersoft\Desktop\ZipTest\";
     
    using (Ionic.Zip.ZipFile zip = Ionic.Zip.ZipFile.Read(zipFile))
    {
        zip.Password = "1234";
        zip.ExtractAll(targetDirectory, Ionic.Zip.ExtractExistingFileAction.DoNotOverwrite);
    }
     
    Console.WriteLine("Zip file has been successfully extracted.");
    Console.Read();
    

    Source: https://codesnippets.fesslersoft.de/extract-a-password-protected-zip-file-using-dotnetzip/

提交回复
热议问题