'Could not find a part of the path' on a Read Text File Activity

I am encountering an intermittent issue with the Read Text File activity when it is configured to use Local Path.

Context

I created a custom library that contains a workflow called REST_AffecterDemande. Inside this workflow, there is a Read Text File activity with the Local Path option enabled.

Issue

When I use this custom activity (REST_AffecterDemande) from a second robot, it sometimes fails with the following error:

REST_AJouterComment: One or more errors occurred.
(Could not find a part of the path 
'C:\Users\AFCO\Documents\Projets GIT\Test_LIBCOM\GPS\API REST\REST_AjouterCommentaire\REST_Endpoint_AjouterCommentaire.txt')

Key Point – Intermittent Behavior

What makes this issue particularly confusing is that:

  • The error appears randomly, without any change to the Read Text File activity or the library.
  • It can disappear just as mysteriously, again without any modification to the workflow, activity configuration, or deployment.

Expected vs Actual Behavior

  • The resolved path unexpectedly includes the local project path of the robot machine:
C:\Users\AFCO\Documents\Projets GIT\Test_LIBCOM\
  • This is not the expected behavior.
    Since the activity is configured with Local Path, it should resolve the file path relative to the library root, not the consuming robot’s local project directory.
  • The expected relative path inside the library is:
GPS\API REST\REST_AjouterCommentaire\REST_Endpoint_AjouterCommentaire.txt

Question

  • Is this behavior expected when using Local Path inside a custom library?
  • Could this be a known issue or race condition related to library resolution or caching?
  • Has anyone experienced similar random path resolution issues when consuming libraries across different robots?

Environment

  • UiPath Studio: 25.10.3
  • UiPath.System.Activities: 25.10.5

have a look here:

@alfred.couvreur.ext

From you scenario it looks like you are building the path dynamically, note that it can refer the path of the consuming robot if you using any local path of the library.
So in order to resolve this, you need to use library path as hardcoded or some external source referencing in the library such some text file or config file or asset etc.

If you can share some more details on how you are building path like expression or screenshot etc, then we can suggest.

In the library’s Workflow, the Read Text File activity looks like this :

As explained above, I am using the (local path) option of the activity and the harcoded path seen is the relative path inside the library :
“GPS/API REST/REST_AjouterCommentaire/REST_Endpoint_AjouterCommentaire.txt”

Thank you for your reply.

I tried using UiPath.Constants.Project.Location as a prefix for the file path, as suggested, but I kept encountering compilation errors. It appears that the Constants dependency is no longer available (or may be deprecated) in the Studio version I am currently using.

As an alternative, I tested prefixing the path with Environment.CurrentDirectory, and this approach seems to work consistently so far.

Would you recommend using Environment.CurrentDirectory as a standard prefix in this kind of library-related scenario, or is there a more appropriate or future-proof approach?

we would recommend that you will breakdown clear on what is needed and where it fails. For the breaking down maybe the following pattern can help:

Custom Library - CL
Consuming Process - CP

Location of CL like: C:\RPA\LIBs\CL
Location of CP like: C:\RPA\LIBs\CP

so now you can describe the scenario along with its expectations.

we would use it for the further RnDs, which should be done

About Constants also have a look here:

When the CP location is needed within the CL, then pass it onto via an input argument

@alfred.couvreur.ext

As per the screenshot, it looks like you are using a short path, so wherever you are consuming this library or any project, bot will look for this path in the project folder.

So, to make it stable, you need to ensure the folder structure you provided should be present in project folder, if not, make necessary changes or build dynamic path (by combining path in the screenshot) and the expected directory where your folder structure will be available (parent path).

You can create a in argument as well to pass the parent path.

Thanks for the clarification. Let me break down the scenario more explicitly using the suggested pattern.

Scenario breakdown

Custom Library (CL)

  • Physical location (example):
    C:\RPA\LIBs\CL
  • The library contains a workflow using Read Text File
  • The file path is hardcoded and intended to be relative to the library root, for example:
GPS\API REST\REST_AjouterCommentaire\REST_Endpoint_AjouterCommentaire.txt
  • The Local Path option is enabled on the activity

Consuming Process (CP)

  • Physical location (example):
    C:\RPA\LIBs\CP
  • The CP invokes the custom activity from the library
  • No path is passed in as an argument; the library is expected to resolve its own internal files

Expected behavior

The file path inside the library should be resolved relative to the CL root folder, regardless of where the CP is located.

Actual behavior

Intermittently, the file path is resolved relative to the CP project folder, resulting in errors such as:

Could not find a part of the path C:\RPA\LIBs\CP\GPS\API REST\...

This happens without changes to the library or consuming process and may disappear on its own a


About UiPath.Constants.Project.Location

I attempted to explicitly anchor the path using:

Path.Combine(UiPath.Constants.Project.Location, "<relative path>")

However, on my Studio version, this fails to compile because UiPath.Constants does not appear to be available anymore (possibly deprecated or no longer exposed).


Current working solution

What works consistently so far is:

Path.Combine(
  Environment.CurrentDirectory,
  "GPS\API REST\REST_AjouterCommentaire\REST_Endpoint_AjouterCommentaire.txt"
)

This resolves the file correctly at runtime and eliminates the random behavior.

Question / confirmation

Given this:

  • Would Environment.CurrentDirectory be considered an acceptable and supported approach to anchor file paths inside a library?
  • Or is the recommended design to avoid internal file resolution altogether and instead pass required paths (from the CP) as input arguments to the library?

At the moment, the intent is for the library to remain self-contained unless CP-specific paths are explicitly needed.

I would check if the file existed first with the same file path every time before reading it. That would give some clarity of the location of the file.