How to zip files using invoke method?

I want to zip files in a folder using some backend activity which is UI independent.

The solution available in forum Compress files to .zip format, Unzip Files using invoke method - #2 by badita and Problem with recording right click did not provide any concrete solution to the problem at hand.

The alternative of invoke method using System.IO.Compression looked promising but I could not find System.IO.Compression**.ZipFiles** in “browse for types” option. Please provide a solution which could be utilized in multiple .xaml files across multiple laptops.

Do you have .NET 4.5 installed on the machine?

ZipFile.ExtractToDirectory(zipFile, extractPath)

1 Like

I believe you are referring to method name “CreateFromDirectory” since I need to zip files (not extraction) which is also available in forum (link attached in above request). Unfortunately, the licensed UI Path (I have) shows .NET version of 4.0.
I think that is the reason for non- availability of option .zip file in System.IO.Compression. Is there any way I could get it in UIPath version I have?
Attached screenshot of UIPath for reference.

Do you have 4.5 installed on your machine?

1 Like

One thing to note - UiStudio 2016.2 refuses to install without .Net framework 4.6 installed, so I guess we can take that as a given.
.Net framework 4.0.30319.42000 is actually 4.6 (because Microsoft ^^).

@igul - if you want a solution that can be used from multiple .xaml’s, build an activity for it. That’s the most robust way to make sure it works the same way in all and is not tampered with for no reason.

Regards,
Andrzej

2 Likes

Thanks. As a workaround, I managed with the invoke method referring notepad suggested in one of the articles I linked. However, it would be great if we could have zip file extension by default in UIPath.

1 Like

Hello All,

Uploaded the xaml which zips an entire folder to into a .zip.

This can be achieved by using Invoke Method.Select Target Type as “System.IO.Compression”,Method Name as “CreateFromDirectory”

Zipping a folder.xaml (5.9 KB)

1 Like

Hi ,

Here is the activity to zip and unzip the files and folders with password.

Regards
Balamurugan.S