How to check if multiple folders exists or not?

I have to check whether in share drive all 5 folders exists or not
can it be done in single activity?

hello @shilpashree.mohanty

first Create Variable
folderPaths(Array of String ) store all your folder path then

Take assign activity and ut this LINQ

allFoldersExist = folderPaths.All(Function(folder) System.IO.Directory.Exists(folder))

Regards
Dheerandra Vishwakarma

suppose, i do this
and found that 2 folders dont exists
how can i create those 2?
:slight_smile:

@shilpashree.mohanty

yes first use this will identify missing folder

missingFolders = folderPaths.Where(Function(folder) Not System.IO.Directory.Exists(folder)).ToList()

then for folder creation use below linq inside invoke code

missingFolders.ForEach(Sub(folder) System.IO.Directory.CreateDirectory(folder))

Regards

we are not allowed to use invoke code
what would be the data type for **missingFolders **

And could you please suggest linq query to create folders

@shilpashree.mohanty

missingFolders has dataype List of string.

and you can use for each inside

Inside For Each use a Create Directory Activity:

  • Set Path to item (current folder path in the loop).

Regards

hey,
dint get you

  • Set Path to item (current folder path in the loop).

The image shows a portion of a code editor with variables being assigned values and conditions, including "folderPat," "allFolder," and "missingF." (Captioned by AI)

this is my query

hey,
dint get you

  • Set Path to item (current folder path in the loop).

The image shows a portion of a code editor with variables being assigned values and conditions, including "folderPat," "allFolder," and "missingF." (Captioned by AI)

this is my query

@shilpashree.mohanty

inside for each just implement the code to create folder
Regards

what would be current folder path?

it will be item which iterating for loop

1 Like

@shilpashree.mohanty

convert type agrument of for each to string

The image shows a dropdown menu in UiPath Studio selecting an argument type, with "Boolean" highlighted, under the "For Each" activity configuration for a variable named "currentItem." (Captioned by AI)
Regards

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