Catering for illegal characters within a .zip folder to be extracted

Hello all

I’m currently working on a bulk-unzipper process.

I’m running into issues where if a file within the .zip has an illegal character, (eg: “:”), it throws an exception when the process attempts to extract the file (using Invoke Method → System.IO.Compression.ZipFile → ExtractToDirectory)

image

I’ve read some threads but I am not clear on how I can cater for this when the file is within a .zip.

I’d appreciate any help!

Here’s a solution using Invoke Code activity.

Inspired by these two posts on stackoverflow which deal with this issue in C#

1. Ensure you have the package System.IO.Compression.ZipFile installed - NuGet Gallery | System.IO.Compression.ZipFile 4.3.0

2. Use an invoke code with the following code

Dim extractPath As String
Using zip As ZipArchive = ZipFile.Open(zipFilePath, ZipArchiveMode.Update)
      For Each entry As ZipArchiveEntry In zip.Entries
    extractPath = outFilePath + String.Join("_", entry.Name.Split(Path.GetInvalidFileNameChars()))
          entry.ExtractToFile(extractPath)
   Next
End Using

This basically opens is file in the zip, and extracts it with a clean file name.

I have two arguments, zipFilePath (the zip file to unzip) & outFilePath (the folder to put the contents)

image

3. Import System.IO.Compression Namespace
image

XAML attached

extractZip.xaml (6.5 KB)

1 Like

Nailed it, thank you!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.