Studio Web - Read text activity error

Error: System.AggregateException: One or more errors occurred. (Could not find file ‘/tmp/home/UiPath/RemoteAgent/Projects/6192716e-e799-45d2-8a21-4d27378aedbf/C:\Users\xxx\Downloads\UiP var test file.txt’.) (Could not find file ‘/tmp/home/UiPath/RemoteAgent/Projects/6192716e-e799-45d2-8a21-4d27378aedbf/C:\Users\xxx\Downloads\UiP var test file.txt’.) (Could not find file ‘/tmp/home/UiPath/RemoteAgent/Projects/6192716e-e799-45d2-8a21-4d27378aedbf/C:\Users\xxx\Downloads\UiP var test file.txt’.)
at UiPath.Core.Activities.TaskAsyncCodeActivityWithResult1.EndExecute(AsyncCodeActivityContext context, IAsyncResult result) at System.Activities.AsyncCodeActivity1.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
System.IO.FileNotFoundException: Could not find file ‘/tmp/home/UiPath/RemoteAgent/Projects/6192716e-e799-45d2-8a21-4d27378aedbf/C:\Users\xxx\Downloads\UiP var test file.txt’.
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode, Boolean failForSymlink, Boolean& wasSymlink, Func4 createOpenException) at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func4 createOpenException)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable1 unixCreateMode) at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize) at System.IO.File.ReadAllText(String path, Encoding encoding) at UiPath.Core.Activities.ReadTextFile.<>c__DisplayClass19_0.<ExecuteAsync>b__0() at UiPath.Core.Activities.Retry.Do[ResultType](Func1 action, Int32 timeoutMS, Int32 retryCount)

@IoT

When this error is occurring? while indicating the Ui Element or execution time?

  1. Verify the file exists at the specified location.

  2. Avoid hardcoded paths like:

    C:\Users\xxx\Downloads\UiP var test file.txt

  3. Store the file inside the UiPath project folder or download it to the robot machine.

  4. Use a relative path or dynamic path:

    Path.Combine(Environment.CurrentDirectory, “UiP var test file.txt”)

  5. Before reading the file, check:
    System.IO.File.Exists(FilePath)

  6. If running from Orchestrator/Automation Cloud, use a Storage Bucket or a file accessible to the robot.

This is the correct answer.

When you execute on the serverless runtime, your hardcoded paths are evaluated on that cloud runtime and not on your own machine.

You could debug/run it on your local environment via the UiPath Assistant though, which is another way to solve this issue.

For the record → we are aware this can be confusing and are thinking of ways to improve the experience a bit.

ok now makes sense @loginerror .
Cause i’ve noticed that if attempting via Assistant locally should run ok. @ashokkarale it’s on debug step run and everything seems set up properly..
Issue is as @loginerror mentioned.

And what if i don’t have a local assistant installed @loginerror ?? how can i then debug run?

That depends on your use case.

If your goal is to run this automation unattended on the serverless, then you have a few options:

  • Upload the content somewhere, and dynamically retrieve it at runtime, for example via the Get File or Folder O365 activity:
  • Save the text first with the Write Text File activity (this will hardcode it and write it at runtime, so it will exist on the serverless when you test it)
  • You can also store it as an Orchestrator asset or storage bucket file.

I’m sure others can chime in with more options; I don’t think the above are exhaustive, but they should give you the right idea.