Relative path error

The error has to do with UiPath’s relative working directory as it calls into other modules. I found this via the following:

  1. Call module Main in …\Folder 1\main.xaml
  2. …\Folder 1\main.xalm makes a call to …\Folder 2\Login.xaml (explicit path, still ok here)
  3. …\Folder 1\main.xaml makes a call to “Login.xaml” (relative path, call still works).
  4. …\Folder 1\Login.xaml makes a call to …\Folder 2\Open IE11.xaml (explicit path, still ok)
  5. …\Folder 2\Open IE11.xaml makes a call to “Close Idle Window” (relative path, BREAKS).
    This relative path should be using the …\Folder 2\ directory, but instead UiPath looks for the file in the …\Folder 1\ directory.

During development, UiPath defaults for anything within the same folder (“…\Folder 1\” to start this case) but does not update when calling to outside scripts that themselves have a relative path.

1 Like

Hi,

This is usual behaviour - a process has one entry for working directory, for UiPath that’s supplied from the entry (starting) workflow.
You can change it with a Directory.SetCurrentDirectory call.

I’d actually recommend to restructure your folders and do a tree hierarchy, f.e.:

  • Root (contains Main.xaml and other high level workflows)
  • Root/Folder1 (contains Folder1 specific workflows)
  • Root/Folder2 (contains Folder2 specific workflows)

That way you can always use a path relative to the entry working directory, so you can move your whoel project to a different location without it braking. Explicit/full paths have a tendency to break on migrations/network changes, which is an issue that’s just waiting to happen in the future.

Alternatively, you could store the paths (or working directories paths) externally, f.e. in Orchestrator assets, and use that in a way similar to a configuration file.

Regards.

1 Like

Hi,
how can I use setCurrentDirectory in UiPath?
I try assign activity, but, as the method does not produce a value, I have validations errors.

CurrDir.xaml (5.8 KB)

2 Likes

thank you @vvaidya, I don’t really understand how this magic works… But is works! :slight_smile:
Is “CurrentDirectory” a preset variable?
Thank