Save a file when Bot runs unattended on a different machine

My process saves a PDF file. But when I publish the process on the Orchestrator the current directory file path is changed as its a different machine.
I am using Enviornment.CurrentDirectory.

Suppose the file path currently my bot is accessing is this:

and when I run the bot unattended it changes:
image

What will be the best practice so that my bot saves the PDF file successfully in the right directory.

Thanks for the help…
Any suggestion is deeply appreciated.

@chauhan.rachita30

If you are going to save the files inside your project folder then provide Relative path instead of Absolute path.

Hi,

If we use relative path or System.Environment.Currentdirectory, C:\Users\[username]\.nuget\packages\[packagename]\[version]\lib\net45 is normal if run published process.

if we need to access the above path, use the absolute path as the following. Or it might be better other environment variable.

\\usrprf01\UserProfiles\UserFR\xxxx\Documents\UiPath\Snoq Canyon\DisclosureProcess\PrepareDisclosurePackage

Or we might be choose way to change current directory, using Directory.SetCurrentDirectory method.

Regards,

2 Likes

I am thinking what path I will give in the config so that it will remain constant in Production/Go live environment. Like what should be the best practice when we are saving a file in an automation.

@chauhan.rachita30

If you have any shared drive to place the Bot output reports then write that shared drive location in config file. So that you no need to change the folder location everytime.

If you don’t have any shared drive then save the output files inside the project folder and write relative path into Config file. So that it will be constant and you no need to change it everytime.

2 Likes

Depending on your needs, you can also configure Storage buckets in Orchestrator which has a couple different backend storage services that it supports include Local File System / Network File Share.

As you’ve noticed Saving Files to disk in a relative path is typically not recommended if you are looking to run the process with multiple Users or Robots as it would be Per Machine Per User Per Package Version (or wherever you have configured your Nuget Packages to download, at the very least Per User). This is not generally desired unless you are temporarily keeping the files and discarding them during processing, but then I would more likely suggest a OS Temp Folder as you still need to worry about File Space on a per package version if you need to clean up storage.

We use a common NFS that is accessible by all Robot User’s organized by Environment then by Processes. If performance is required we Copy/Process files locally to the Robot and copy back to the NFS. We will be looking at the Storage Buckets in the near future, only real difference is the meta data of the files would be store in Orchestrator’s DB and we’d have to leverage the API from external applications to locate the desired file.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.