Display all files in folder in UiPath Form

Hello all my end goal is to import the file that user select from the form.

The folder can change and so is the file name. So this is like dynamic file names. I want to display all the files in form type. Later the user clicks the desired file from the form and the file my be opened.

I am not aware about a lot with UiPath. Can someone help if such thing is possible?

Regards.

Hi @tarangmehta1195,

I assume your process is an Attended process, with someone monitoring it/interacting with it?

You could get the folder with the following:

Folder = System.IO.Directory.GetDirectories("YourFilepath","YourFolderName*")(0)

Then, get the files in the folder:

Files = System.IO.Directory.GetFiles(Folder) - Files is an Array of Strings

You can then use the Array in a User Input Dialog activity, with Files in the Options property. This will display either a dropdown or list of buttons that the user can select from:
image

The chosen file will then be outputted as a string and you can do whatever you need with it.

1 Like

@william.coulson Thank you for the response. Do i use assign function? It will be better if you can share a short example. I am still in learning phase. Regards.

@william.coulson i tried using assign function. I am getting error.

So i used file.ToString. But the output is as follows. Can you tell me where i am wrong?

https://docs.uipath.com/activities/other/latest/workflow/input-dialog
we would use the configuration:

options - a string Array
grafik

OR
Options String - a with ; separated string
grafik

From the screenshot we do see File as String array used at the input options strings and here it is missmatching

We recommend not to use Classnames as Variable names so do not use Variable names like File

1 Like

hi @ppr,
Even if i change the name of the variable the output is the same. What should i write in Input dialog then?

when using a string array use the other option field which is expecting the string array

1 Like

@ppr got it thanks. And one final question How do i get only file name and not full path. Now I am getting output but full path.

one of some more options:
grafik

Path.GetFileName(YourStringVar)

it shows overload error. I am using following as input
Folder = System.IO.Directory.GetDirectories("YourFilepath","YourFolderName*")(0)

Then, get the files in the folder:

Files = System.IO.Directory.GetFiles(Folder) - Files is an Array of Strings

we do see that the last question is drifting away from the initial topic quesiton. As we prefer 1 Topic = 1 case (so thers can more easy find solutions) feel free to open a new topic when the following cheatsheet is not solving

[CheatSheet] - Filesystem APIs - News / Tutorials - UiPath Community Forum

1 Like

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