I want to read folder path from config file as Path.Combine(Environment.CurrentDirectory,"Data","FolderPath")

I want to read folder path from config file as Path.Combine(Environment.CurrentDirectory,“Data”,“FolderPath”)
I tried as(Config(Folder)) - “Data”, “Folderpath” and also data, folderpath
Path.Combine(Environment.CurrentDirectory, Config(Folder).tostring)
Bot tells that folderpath doesn’t exist, When i hardcode it, its working

Can anyone help me out to solve this?

@HENRY_SOLOMON

Can you please show your folder path in config and the actual folder pth please

Cheers

Hi @HENRY_SOLOMON

When reading a folder path from a configuration file in UiPath, you can use the Path.Combine method along with the Environment.CurrentDirectory to construct the full folder path. Here’s an example of how you can achieve this:

Assuming you have a configuration file (e.g., config.xlsx) that contains the folder path, create an Excel Application Scope activity to read the configuration file.
Use the Read Cell activity within the Excel Application Scope to read the folder path from the configuration file. Let’s assume the folder path is in cell A1.

  • Set the Range property to “Sheet1!A1” to indicate the cell to read.
  • Store the output value in a variable, let’s call it folderPath.
    Use the Path.Combine method to construct the full folder path using the Environment.CurrentDirectory and the value obtained from the configuration file.
  • Assign the following expression to a variable, let’s call it fullFolderPath:

Path.Combine(Environment.CurrentDirectory, folderPath.ToString)

Now you can use the fullFolderPath variable wherever you need to access files or folders within that path.

Thanks!!

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