How to zip files using invoke method?

file
code

#1

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 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.


#2

Do you have .NET 4.5 installed on the machine?

ZipFile.ExtractToDirectory(zipFile, extractPath)


#3

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.


#4

Do you have 4.5 installed on your machine?

https://www.microsoft.com/en-us/download/details.aspx?id=30653


#5

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


#6

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.


#7

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)


#8

Hi ,

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

Regards
Balamurugan.S


#9