C# .Net 3.5 Unzip zip file no 3rd party

后端 未结 4 707
闹比i
闹比i 2021-01-22 10:36

I am writing a Winform application in .NET 3.5, and I need unzip a .rar or .zip file.
I found many things, but I didn\'t found none 3rd party. I couldn\'t change to .NET 4

相关标签:
4条回答
  • 2021-01-22 11:02

    Actually, .NET 3.5 does .zip files using the DeflateStream. You have to handle the headers yourself, but PKWare has published the specification and you can create structs and use Streams.

    There is no need of third party code…but, you do have to approach it in a more traditional, old school manner. They don't exactly unzip themselves.

    0 讨论(0)
  • 2021-01-22 11:04

    The .NET framework doesn't support .RAR files, and didn't have support for Zip files until .NET 4.5.

    If you want to support .ZIP (or .RAR) in .NET 3.5, you'll need a third party solution. The DotNetZip library, for example, supports .NET 3.5, and is fully functional for handling of .ZIP files.

    There are commercial products which support RAR, such as Chilkat RAR.

    0 讨论(0)
  • 2021-01-22 11:06

    How about http://www.codeproject.com/Articles/645214/Compress-Decompress-Zip-Files-w

    Not the best solution, but works well if you need basic zip/unzip functionality.

    Disclaimer: I'm the author of the article.

    0 讨论(0)
  • 2021-01-22 11:14

    If you only need to uncompress zip file, You don't need to add an external third party library.

    Only you need is Add a reference to Microsoft Shell controls and Automation from the COM tab in the Reference Manager in Visual Studio.

    private static void Unzip(String sourceFile,String destination) 
    {
        Shell32.ShellClass sc = new Shell32.ShellClass();
        Shell32.Folder SrcFlder = sc.NameSpace(sourceFile);
        Shell32.Folder DestFlder = sc.NameSpace(destination);
        Shell32.FolderItems items = SrcFlder.Items();
        DestFlder.CopyHere(items, 20);          
    }
    

    With this, you don't have to distribute any additional dll file with your application.

    0 讨论(0)
提交回复
热议问题