Unzip Files using invoke method

Hello everyone,

@andrzej.kniola provided steps to do this here but I can’t seem to get the class to unzip a file. I’ve looked at This .Net library but I can’t this get to work.

Can you guys please point me in the right direction?

here is the .XAML Two assigns and an invoke method. I also added <x:String>System.IO.Compression</x:String> to the XAML file.

unzip.xaml (5.6 KB)

6 Likes

I’m opening your workflow and I get this warning 'ZipFile' does not have a public static method named 'ExtractToDirectory' matching the parameter types, generic type arguments, and generic type constraints supplied to InvokeMethod.

Basically you’re trying to call ZipFile.ExtracttoDirectory() instead of ZipFile.ExtractToDirectory(zipFile, extractPath)

After setting the parameters (zipPath, extractPath) for the ExtractToDirectory method it will work.

Aren’t you getting the same?

11 Likes

Hi @badita exactly like I was not using the correct targetType… imma try to set the parameters later on and will let you know. Many thanks :smiley:

It should work when you’ll set the params, although I have to say that making dedicated activities for Zip/Unzip made our life much easier, especially for less technical designers - it’s easy to miss something when it’s hidden in Invoke’s params, but much clearer when you have it directly in Properties.

So in the end I’d definitely recommend adding some Custom activities - it’s a good way to practice too :slight_smile:

2 Likes

Yeah, yeah, it worked. Thank you @badita and @andrzej.kniola… to have you both helping me with this was like having two golden globe nominees on the stage… :stuck_out_tongue_winking_eye:

@andrzej.kniola… so you are sayin’ that is better to use this custom activity or to create something more like the unzip activity with VB, and nupackage and all that kind of stuff? :slight_smile:

Here is the .XAML for everyone’s usage.
unzip.xaml (5.8 KB)

12 Likes

If it’s a one-off usage, go with the .xaml as you have. But if you’ll need this functionality in multiple projects (with Zip/Unzip it’s a pretty good guess that you’ll use it in different places) or if you’ll be zipping a lot of files, I’d definitely go with a compiled CodeActivity (.dll packed to a .nupkg).

I’d go with these questions when thinking about creating a custom CodeActivity:

  1. Will it be used in multiple projects or in many places across a project?
  2. Are arguments enough to fully use the activity?
  3. Is the operation fully encapsulated within?
  4. Is the operation straightforward enough to be understandable without the verbosity of a workflow?
  5. Is speed of execution important? (compiled code is faster, as a rule of thumb)
  6. Is it easier/more readable to do it from code?
  7. Is the functionality relatively static, as in it won’ need to change often?

If you answer Yes to most of them, it’s a good candidate. It can still vary case-by-case, but usually for simple utility code (zip/unzip, read/write, data parsing etc.) it’s a one-and-done job to make an activity which you won’t need to worry about later.

Sooner or later you will probably need a custom activity for something, might as well get to know how to build them on the easy stuff.

Regards,
Andrzej

5 Likes

Hi
Can i know the exact target type as in System.IO.Compression there are other subcategores also which to select for this i am not getting…please help
in this example

1 Like

i cant extract target type as system.IO. compression.zip .

Could you please asssit or suggest some other workaround.

Thanks,
Suchi

Hi,
There is custom activity already hosted in forum .
Please download nuget package from here and add from package manager.

2 Likes

For Zip/unzip you need the library System.Io.Compression. You probably have the library system.io only

After you add the System.Io.Compression you can browse the library
System.IO.Compression.ZipFile under the TargetType Property of the Invoke Method Activity
image

IF you still dont see it try restarting Studio.
Else try using the XAML that was posted from one of the users above.

1 Like

i had used the workflow but, the robot can’t access the unzipping directory (access denied) !!!

Hi @abdel,

you can use this to unzip the files.

Regards
Balamurugan.S

1 Like

i tried it but it did not workunzip.xaml (7.3 KB)

Hi @abdel,

It is working for me. Here I have attached xaml with sample zip file.

Files :abdel.zip (3.5 KB)

if possible , can you share the zip file. So that I can try it here. If you feel it is confidential , you can send it as message.

Regards
Balamurugan.S

Regards
Balamurugan.S

Hello everybody, how can i extract with the same filename?

Greetings.

Hi @sermuolo,

Here I have attached the sample for you that to extract the same name.
If you have different name of file Inside the zip file , you can rename it after extract the zip file by using File rename.

UnZip.zip (4.3 KB)

I have attached the sample that is developed in the version 2018.3.

Regards
Balamurugan.S

1 Like