Search code examples
filterunzipchilkat

Chilkat unzip files only from root directory


zip.UnzipMatching("qa_output","*.xml",true)

With this syntax I can unzip every Xml in every directory from my zip file and create the same directory structure.

But how can I unzip only the xml in the root directory?

I cannot understand how to write the filter. I tried with "/*.xml" but nothing is extracted. If I write "*/*.xml" I only extract xml files from subdirectory (and I skip the xml in the root directory!). Can anyone help me?

example of a zip files content:
a1.xml
b1.xml
c1.xml
dir1\a2.xml
dir1\c2.xml
dir2\dir3\c3.xml

with unzipmatching("qa_output","*.xml", true) I extract all this files with the original directory structure, but I want to extract only a1.xml, b1.xml and c1.xml. Is there a way to write filter to achieve this result, or a different command, or a different approach?


Solution

  • I think what you want is to call UnzipMatchingInto: All files (matching the pattern) in the Zip are unzipped into the specfied dirPath regardless of the directory path information contained in the Zip. This has the effect of collapsing all files into a single directory. If several files in the Zip have the same name, the files unzipped last will overwrite the files already unzipped.