How to Get only Zip folders from a folder

Hello,

I have a use case where i have to download all the attachments from outlook into a folder.
Now,
1.I have to check if there is any zip folder form the downloaded files from downloaded folder.
2. If there is any zip folder i have to extract into downloaded folder where remaining documents are saved.

Now my doubt is how to get only zip files from the folder.
Please help me, Thanks in Advance

Hi

You can use this code

Directory.GetFiles("yourDirectory","*.ZIP")

This will give you only ZIP files from particular directory

Thanks,
Prankur

2 Likes

use Directory.GetFiles(“E:\Attachment Folders”+item.From.DisplayName,"*.zip",SearchOption.AllDirectories) in assign activity.

2 Likes

HI,

Change the for each properites->type argument into string

Regards,
Arivu

1 Like

Hi @PrankurJoshi i have to get all files folder while getting all files if there is any zip files i have to extract if not there i have to work with other documents

so how validate using if condition

Thanks for the quick response plrase help me

how to validate using if condition @pathrudu
Thank you so much for your response

Now that you already have file names you can simply check this

string ext = Path.GetExtension(myFilePath)

This is will give file extension which can be used in if condition

if ext=".ZIP"

Thanks,
Prankur

2 Likes

use Path.GetExtension(filePath) to check the extension for zip files you will get .zip

OutLookAttachement.zip (6.5 KB)

Can you please check my work flow once where i am doing wrong? I have almost tried

Hey @pathrudu,

In the below image i am able to get the extension and able check the if condition, now how to pass that particular zip file path to the activity in properties folder

what ever the path you provided in Path.GetExtension()

In your workflow, the “GetFiles” array contains the full path of each files in your specified directory and you gave each string name as ‘File’ in the for each loop. So You can pass the source file path for ‘unzip file’ activity and path for ‘delete’ activity as “File”.

Regards,
Nimin

Thank you @pathrudu and @PrankurJoshi it worked.

Thank you soo much

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.