How to unzip a zip file in Windows Mobile?

I need to programmatically unzip the zip archive to a folder on Windows Mobile. Is there an easy to use API that I can use directly or do I need to use some external library?

+3
source share
3 answers

You need an external library. There is zlibce.dll, a native DLL that you can use if C ++ is your thang.

If .NET is your thing, I can recommend DotNetZip , which runs on .NETCF 2.0, is free, open source, and has a good document, good performance. The source DotNetZip distribution has a CF-Unzipper project that you can view and compile; It demonstrates how to unzip files on a device. Here is a link where you can view the code for the device.

This is a snippet of zip-important pieces of code. It is unpacked into a directory that takes its name from the zip file (without the .zip extension).

    private void UnzipSelectedFile()
    {
        string parent = System.IO.Path.GetDirectoryName(_selectedpath);
        string dir = System.IO.Path.Combine(parent,
            System.IO.Path.GetFileNameWithoutExtension(_selectedpath));
        try
        {
            using (var zip1 = new Ionic.Zip.ZipFile(_selectedpath))
            {
                foreach (var entry in zip1)
                {
                    entry.Extract(dir, true);
                }
            }

            // re-populate the treeview with the extracted files:
            AddChildren(tvFolders.SelectedNode.Parent);

        }
        catch (Exception ex)
        {
            MessageBox.Show("Exception! " + ex);
        }
    }

Here is a link to the online version of the document for the library.

+7
source
0

No matter what language you use, you can use Info-ZIP as an external executable file.

-1
source

Source: https://habr.com/ru/post/1704319/


All Articles