Custom activity does not take relative path

Standard UiPath activities accept relative paths, but the same isn’t true for custom activities.

For e.g. Suppose I have a folder named “Temp” in my project directory. I now use the UiPath activity “Path Exists” and set the Path Type to Folder. For the Path input parameter, I provide “Temp”. If a folder already exists called “Temp”, it returns true. Or else, it returns false.

I have created a custom activity called Ensure Folder to check if a particular folder path exists and create it if it doesn’t exist. I published this custom activity using a library. When I then run the custom activity and provide “Temp” as the input path, it creates the folder inside the .Nuget packages folder, where the custom activity’s .DLL file is located:

C:\Users<Username>.nuget\packages<LibraryName>\1.0.4-alpha\lib\net45\Temp.

Why does this happen? How can I set a custom activity to also accept relative filepaths like a standard UiPath activity?

As you already noticed the relative path is based on project / component location
Maybe you can manage by calling the component with:
Path.Combine(Environment.CurrentDirectory,“Temp”)

1 Like

Thank you. Yup. I already used Path.Combine(Directory.GetCurrentDirectory,"Temp). But that is inconsistent. I would have to explicitly mention to all users of the custom activity to use full paths.

My understanding was that once a custom activity was created, it would be entirely similar to a regular UiPath activity. Even standard UiPath activities rely on packages in .nuget. So why is their behaviour different?

1 Like

From my understanding, if you use Directory.GetCurrentDirectory it will use the directory that is local to your project that is running. If you want to use relative path, you need to leave off the current directory. But, I haven’t messed with custom activities that much. I do know that when you publish a Library, you can use relative paths, as long as you don’t use the current directory with it.

There could be some better info on this somewhere on the forums, but am not sure.

@ClaytonM
as mentioned in the discussion. Using a relative path on the library will be anchored to the library base and not to the consuming project base

1 Like