I need to programaticaly unpack a zip archive to folder on Windows Mobile. Is there an easy to use API that I can use directly or should I go with some external library?
If you're using .Net Compact Framework you could go with http://www.icsharpcode.net/OpenSource/SharpZipLib. I believe it supports running on CF.
You need an external library. There is a zlibce.dll, a native DLL that you can use if C++ is your thang.
If .NET is your thing then I can recommend DotNetZip, which runs on the .NETCF 2.0, is free, open source, and has good doc, good performance. In the DotNetZip source distrib, there's a CF-Unzipper project that you can view and compile; it demonstrates how to unzip files on the device. Here's a link where you can view the code for the device app.
This is a snip of the zip-relevant parts of the code. It unzips to 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's a link to an online version of the doc for the library.
Regardless of what language you use you can use Info-ZIP as an external executable.