cancel
Showing results for 
Search instead for 
Did you mean: 

Unzip compressed file (.zip)

Anonymous
Not applicable
Hi All, I need to extract (unzip) a compressed file/folder. Please advice on this. Thanks! Aditya
11 REPLIES 11

You need to create your own VBO for this, take a look at the ""ZipArchive"" and ""ZipFile"" classes on the offical msdn documentation site.

John__Carter
Staff
Staff
Dim f As New FileInfo(Source_Path) Using archive As ZipArchive = ZipFile.Open(Destination_Path, ZipArchiveMode.Update) archive.CreateEntryFromFile(Source_Path, f.Name, CompressionLevel.Fastest) End Using

John__Carter
Staff
Staff
ZipFile.ExtractToDirectory(Source_Path, Destination_Path)

AdamWagner
Level 2
I have tried the solution @John_Carter has suggested. I am getting compile error saying that ZipArchive is not defined. I have added System.IO.Compression.FileSystem.dll to External References and System.IO.Compression to Namespace Imports on the Code Options tab in Initialise stage of the object. I have tried the solution suggested in this topic and it worked well however it is not covering all I would like to do. I appreciate any suggestions. I am working with BluePrism 5 on Windows 7 Enterprise with Service Pack 1  

BastiaanBezemer
Level 5
Hi Adam, What do you want to do in regards to your ZipFile which is not covered in the topic you refered to ?

AdamWagner
Level 2
Hi Bastian Thank you in advance. I have an one-file-archive. I want to decompress that archive save the file under a custom name. Based on your answer and the answer from @John_Carter and msdn documentation I came out with something like this: Using archive As ZipArchive = ZipFile.OpenRead([ZipFileToUnzip])     For Each entry As ZipArchiveEntry In archive.Entries        entry.ExtractToFile([UnzipedFileFullPath])     Next End Using The above code leads to the following error: Description: Compiler error at line 1: Type 'ZipArchive' is not defined.    

John__Carter
Staff
Staff
On the Initialise page you'll need to add a Namespace Import for System.IO.Compression, and External References to System.IO.Compression.dll and I think System.IO.Compression.FileSystem.dll. Adding these is how the code stage can understand what ZipArchive means.

BastiaanBezemer
Level 5
Hi Adam, As John pointed out, NameSpace imports will probably help. If you don't get it to work, don't worry and be pragmatic ? You can already extract a zipfile to a folder, so if you create a temp folder, you can then loop trough it with Utility File management, do your actions, and then delete the tempfolder again.

AdamWagner
Level 2
@John thank you, adding the library System.IO.Compression.dll worked like a charm. @Bastian being pragmatic is a must have in development 🙂 I just wanted to go one step deeper and understand the ""proper"" way of doing it