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)
I’ve read some threads but I am not clear on how I can cater for this when the file is within a .zip.
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)