i have text files in a folder name with timestamps. I want to iterate through all of them. Then read and process them individually in each iteration. But i am not able to figure out how to iterate them. Could anybody suggest me any solution.
Welcome to UiPATH Community buddy…! Thats a great question to start with
you can use Directory.Getfiles(“yourfolderpath”,"*.docx") in a assign activity with outvariable of type array of string named with out_file_path_array
out_file_path_array = Directory.Getfiles(“yourfolderpath”,"*.docx")
(i used docs, if it is a word document or you can use *.txt as well) @akash.kumar
This would give you the array of file paths with which you can iterate through each file like if you want to open each file as well. using for each loop with input as this out_file_path_array and change the type argument as string in the for each loop buddy
Hope this would help you.
kindly try this and let know buddy @akash.kumar
In Assign activity, please do this:
- Create a variable that is an Array of String (String). Let’s say arrFiles as the variable name
- In the Assign activity,
arrFiles = Directory.GetFiles("folderPath", "*.txt")
- Use For Each activity to loop through the array
Did that work for you buddy @akash.kumar
Futhermore, if you are iterating through For Each, to read the files you need item.ToString
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.