How to open a file in a For each?


I have a list of files that I want to loop through. I can see the full path and file name, I use an Assign to create a variable so that I can open 1 file at a time. I found this topic, but when I try to use that variable to open in Notepad nothing happens. What did I do wrong?
SaveLog.xaml (17.6 KB)

Hi @joesparty

In your list of files, i assume you have the full path of the file along with its name and extension.

If not, you can use Directory.GetFiles("Path") to get the list of files to an array.

In the for each loop, use the Start Process activity and in that, give the path to notepad.exe along with the path name of the file you want to open. To do this… refer the link below…

Hope it helps and if this works for you, please mark the answer as the solution so it could help others as well :slight_smile:


Hello @Lahiru.Fernando

Thank you for the response. That is a much simpler way to open the file. I was using the Desktop Recorder to open the file and save in another format. But now that I used your method are the recorder steps still valid?

SaveLog.xaml (10.5 KB)

Hi @joesparty

For those click activities you have under the DO sequence, use an Attach Window activity and attach it to the notepad window and set all those activities within it. Make sure your selector is dynamic for the attach window so that it supports all the files :slight_smile:

Edit: @joesparty I have done the change to this file and it works perfectly…
SaveLog.xaml (12.0 KB)


That’s @Lahiru.Fernando, that gets me very close! I will practice splitting the file name to exclude the .LOG.


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