top of page

How to Unzip Files in UiPath

UiPath is a popular robotic process automation (RPA) tool that allows you to automate various tasks, such as web scraping, data extraction, file manipulation, and more. One of the common file manipulation tasks is to unzip files, which means to extract the contents of a compressed file (such as a ZIP or RAR file) to a specified folder.


In this blog post, I will show you how to unzip files in UiPath using two different methods: the Invoke Method activity and the Unzip File activity. I will also provide some examples and tips on how to use these methods effectively.


Method 1: Invoke Method Activity


The Invoke Method activity is a general-purpose activity that allows you to invoke any method from any .NET class. You can use this activity to unzip files by invoking the ExtractToDirectory method from the System.IO.Compression.ZipFile class. This method takes two arguments: the source file path and the destination folder path.


To use this method, you need to follow these steps:


1. Create a new sequence in UiPath Studio and drag an Invoke Method activity to the workflow.

2. In the Properties panel, set the TargetType property to "System.IO.Compression.ZipFile".

3. Set the MethodName property to "ExtractToDirectory".

4. Click on the Parameters collection and add two parameters: one for the source file path and one for the destination folder path. You can use variables or hard-coded values for these parameters.

5. Save and run the workflow.


Some tips on using this method are:


- Make sure that the source file path is valid and points to a ZIP or RAR file.

- Make sure that the destination folder path exists and has enough space to store the extracted files.

- If you want to overwrite existing files in the destination folder, you can set the Overwrite property to True in the Parameters collection.

- If you want to handle any errors that may occur during the extraction process, you can use a Try Catch activity and catch the System.IO.IOException exception.


Method 2: Unzip File Activity


The Unzip File activity is a custom activity that is part of the UiPath.Compression.Activities package. You can install this package from the Manage Packages window in UiPath Studio. This activity allows you to unzip files without using any code or invoking any methods. It has two properties: Source and Destination.


To use this method, you need to follow these steps:


1. Create a new sequence in UiPath Studio and drag an Unzip File activity to the workflow.

2. In the Properties panel, set the Source property to the source file path and the Destination property to the destination folder path. You can use variables or hard-coded values for these properties.

3. Save and run the workflow.


Some tips on using this method are:


- Make sure that the source file path is valid and points to a ZIP or RAR file.

- Make sure that the destination folder path exists and has enough space to store the extracted files.

- If you want to overwrite existing files in the destination folder, you can check the Overwrite checkbox in the Properties panel.

- If you want to handle any errors that may occur during the extraction process, you can use a Try Catch activity and catch the UiPath.Compression.Exceptions.CompressionException exception.


Conclusion


In this blog post, I have shown you how to unzip files in UiPath using two different methods: the Invoke Method activity and the Unzip File activity. Both methods have their advantages and disadvantages, so you can choose the one that suits your needs best. I hope you found this post useful and learned something new today.

 

Comments


  • linkedin

V & A Waterfront, Cape Town, 8001, South Africa

©2017 BY NEIL VAN WYNGAARD. PROUDLY CREATED WITH WIX.COM

bottom of page