Set current Directory issue

Hi All,

I want to set my current directory to whereever my main workflow is located.

I was going to use invoke method SetCurrentDirectory but I’m not sure how to do it or if that is the right way (I thought if I just ran the invoke method from within the main workflow it would pick up the path to the current workflow and change the but it doesn’t do anything so obvioulsly this is the wrong approach)

Any ideas please?

I want to save a file in a relative path but because my current directory is not what I want it to be (lets say downloads directory) I can’t do a relative save.

Hi Clark,

You can use the Environment.CurrentDirectory property to get the runtime location of your process (Main.xaml). Then, you can concatenate the relative path with the current directory to save the file.

For your activities you can use also relative paths. For example, if you want to read an excel file stored in the same folder as the main.xaml, you can just specify the excel file name (the relative path) in the Read Range activity. But, if you want to download a file in IE, you need to use the absolute path in the Save As dialog (as the relative refers to IE application and not to UiPath process).

Best regards

1 Like

Hi @Silviu,

Thanks for the advice.

I already saw a post where they were using GetEnvironmentalVariable activity and I put that into my main workflow but it didn’t seem to work.



my main workflow is saved in C:\Users\hasee\Desktop\UIPathExamples\CHALLENGES\Challenge1

but when I run the code I the message box returns


which is obviously not the path that my main worflow is saved to and even after the setCurrentDirectory invoke method it doesn’t change.


Here’s the workflow, please let me know if you have an idea about what might be going on.

Main.xaml (8.4 KB)

Many thanks,

I could be wrong but I believe that the directory is based on where the project.json for your workflows is located.

See if anything in this thread helps, although I think it might just be getting the workflow name:

1 Like

Your workflows is running fine on my computer.
Where do you have the Main.xaml file? Is in the same project with the others? Because I saw that in the Invoke Workflow activities you use the full path, which is an indication that the workflow is in a separate project.

1 Like

I checked in this Screenshot, There is no any project.json file.
Can you please check in your desktop location, There must be any project.json file available. image

CurrentDirectory will return you the Path of where project.json file is located in your parent folder. So just create new project or move your project.json file to your project location.

1 Like

sorry posted without checking other posts

Thank you all very much I’m sure it’s the position of the json file as if I click on project in studio


it takes me to


So you were probably all right and I’m too chicken to pick just one of you now.

Thanks all for your help!!