How can i get the excel path with directory get files

how can i get the excel path with directory get files, i need to path as a string value but when i use message box i see system string



it will give you output as array of files

you can use as





Hi @Soudios,

Try something like this, since it returns a string array you need to use array index to get its value.


Hi @Soudios

Try this


i need to assign it as a variable


Use within for each activity


Path=Directory.GetFiles("C:\Users\lrtetala\Documents\UiPath\BlankProcess12\New folder")
For Each

Directory.GetFiles doesn’t return a string with just one file path in it. It returns an array of strings, in other words a list of multiple string values - because it can return multiple files from the folder. Even if there is only one file, it still returns an array. That array will just have only one element in it.

So you need to work with it as an array, not a string. And you don’t need to assign it to a variable. You can just directly use the expression where you need it. If you know there will always only be one file, then this gets you the path and filename of the one file in the folder:


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