Loop through and open files in specified folder


#1

I want to open a pre-defined folder location and to iterate through all xml files within the folder. Double click them to open them in excel so that I can make changes and then save the files as csv file with same file name.

Anyone kknow how to do this. The community UiPAth I have does not have a readXML activity.


#2

and where would the robot exactly take place? you should save all filenames in an array. Use assign and write Array = Directory.GetFiles(Path).
See more in here: https://msdn.microsoft.com/en-us/library/system.io.directory.getfiles(v=vs.110).aspx


#3

What about “For Each File in Folder” found in Studio in Library / Snippets / Loops?
You could update it to get only .xml files by adding file mask: Directory.GetFiles(selectFolder,"*.xml")
Instead of “Wrilte line” you could perform your own action with the file…


#4

Thanks for reply. How does one open an xml file in Excel? (Get UiPath to open each file?)


#5

Hey @Houghwartz Mate :slight_smile:

Check my Existing post where you will get the logic to use ReadXml .

The above post contains a workflow which reads and xml file and create a datatable then you can do some operations on datatable and can write back where you want.

for files reading from directory search on the forum you find a lot of posts :wink: .

Regards…!!
Aksh


#6

Thanks for help. You invoke the ReadXml Method. This might be a stupid question but where do I find "ReadXml to use?


#7

Where do I set the parameters?


#8

Mate check parameters section invoke method activitily properties. There mentioned filename. If you are using for each with directory.getfiles then pass that file name string here.


#9

Sorry was a stupid question. You really helped a lot.