I have multiple Excel files in a folder, and I am using a For Each File in Folder loop to iterate through them. Inside this loop, I want to read each file using the Read Range Workbook (Modern) activity. However, the File option in this activity accepts a value of type IResource. How can I implement this in UiPath? Please provide an example.
Hi @vivek.srivastava ,
You are almost there..
Please amend the following in For Each File in Folder loop
Filter: *.xlsx
Output: CurrentFile Type: IFileInfo
Inside the Loop ,you may use Read Range
FileName = CurrentFile.ToResource
do check and let me know if it works.
Hi @Christopher_R,
Thanks for you quick response but i am unable to find Output: CurrentFile Type: IFileInfo in For each file in folder property. have a look on attached screenshot.
Inside your loop, use the full file path instead of the file object:
CurrentFile.FullName
This works because Modern activities in UiPath automatically handle string paths and internally convert them to IResource.
If Solution works for you please mark as Solution & Happy Automation with UiPath
Please try to print this value( CurrentFile.ToResource) inside for each, it will give you the complete path
Getting error Error ERROR Validation Error CS1061: ‘FileInfo’ does not contain a definition for ‘ToResource’ and no accessible extension method ‘ToResource’ accepting a first argument of type ‘FileInfo’ could be found (are you missing a using directive or an assembly reference?) Main.xaml.
Seems the activity still stays in Classic version.
Could you please print this value inside for each
CurrentFile.FullName
@vivek.srivastava Since Read Range Workbook (Modern) expects an IResource, the good part is—you don’t need to do anything special when using For Each File in Folder.
Inside your loop, just pass the file variable directly.
For example:
-
In For Each File in Folder → variable:
currentFile -
In Read Range Workbook (Modern) → File =
currentFile
That’s it. It works because UiPath already treats that file as a resource internally.
If you instead try using currentFile.FullName (string path), it won’t work with the Modern activity. In that case, either switch to Classic activity or wrap it inside Use Excel File.
Simple flow:
For Each File in Folder → Read Range Workbook → get DataTable
