Not able to loop for multiple files in a folder

Hi,
I am new to UI Path and am trying to build the following:

  • I have a no of xml files in a folder on desktop.
  • I want to upload each of these files to the xml converter page in browser
  • (optional) move the files uploaded each time to another folder on desktop

But When I try to build the program in UI Studio using foreach file in folder function it either keeps repeating the same file (first file) and when I used the Direction.getfile(str) where str is “path”. It keeps giving error of below. I tried everything converting to array of string, object etc but nothing is working. I have about 1000 files to be converted and the browser doesnt accept more than 1 file at a time. Can you please help.

Error: BC30512: Option Strict On disallows implicit conversions from ‘Object’ to ‘String’. The selected value is incompatible with the property type. Main.xaml

Error: Value of type ‘FileInfo’ cannot be converted to ‘String’. The selected value is incompatible with the property type. Main.xaml

Thanks in advance.

Hi @shazia

you don’t need to use the Directory method, you should just provide the path of the folder that contains the files, in your case strPath

Regards

Just put the path to the folder in the “In folder” property of For Each File in Folder. It gets the list of files itself.

Inside the In Folder only need to have the StrPath

Thanks all. I tried putting the path in strPath with strPath as a array with type string but that didn’t work. Directly putting the path atleast didn’t give me any errors. But I still got teh following issues:

  • it kept opening my download folder rather than the folder I was putting the link for.
  • Also, it kept selecting the first file repeatedly instead of moving on to the next file in the folder?

StrPath shouldn’t be an array with type String, but just a String representing your path.

Regarding your other issues:

  • What part of the workflow is opening the download folder? If there’s a popup opening for a file selection, you might probably have to type the address of the desired folder. Do you have this step in your workflow?
  • Can you show us the selector you’re using the select the file?