Read a file Inside of folder

Path → C:\Users\Uipathuser\Taxology\Test_Folder_Data_RPA - Documents\Spain\Alberta Investment Management Corporation\2020\Local Authorities Pension Plan\Allocation data

I have one excel inside of this path & i want to put that excel file path to in excel application scope so how can i do without for each activity?

@pravin_bindage
Directory.GetFiles(“Root Folder Path”,“filenname.xlsx”,SearchOption.AllDirectories)

Hi @pravin_bindage

Check below workflow if you can get your Contains value

Directory.GetFiles(stPath,"*YourContainsValue*.xlsx")(0)

Thanks,

To put the file path of an Excel file inside the path you provided into an Excel application scope in UiPath, you can use the Read Cell activity to read the file path from a cell in an Excel file and the Open Application activity to open the Excel file using the file path.

Here are the steps to do this:

  1. Use the Read Cell activity to read the file path from a cell in an Excel file. Specify the path to the Excel file and the cell containing the file path in the Read Cell activity’s properties.
  2. Store the file path in a string variable using the Assign activity.
  3. Use the Open Application activity to open the Excel file using the file path stored in the string variable. In the Open Application activity’s properties, set the Path property to the string variable containing the file path.
  4. Place the Open Application activity inside an Excel Application Scope activity to use the Excel file within the scope.

Hi,

Below will give you the latest excel file in the folder.

Directory.GetFiles(Path+“",”*.xlsx").OrderBy(Function (d) New FileInfo(d).LastWriteTime).Where(Function (n) Not Path.GetFileName(n).Contains(“~$”)).Last

What if filename is not known
@sangeethaneelavannan1

@pravin_bindage Directory.GetFiles(“Root Folder Path”,“*.xlsx”,SearchOption.AllDirectories)(0)

2 Likes

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