Using environment shortcuts in directory.getfiles

Hi,

I’m trying to write a simple job that will copy log files from the robot’s machine to a shared drive. I was going to do this with a “For Each” loop for directory.getfiles(“%localappdata%\UiPath\Logs”) but that does not seem to work - it seems to look for the directory I’m working in, plus “%localappdata%\UiPath\Logs”

Is there another way to use %localappdata% in this way? I can’t hard code the path as it will vary depending on the username of the robot

If it varies only with the user name, then you can get the user name and build the path -

strUserName = Environment.UserName

And then you can use like below -

strPath = "C:\" + strUserName + "\UiPath\Logs\"

And also you get the path of special folders using the Environment object.

Reference -

Regards,
Karthik Byggari

1 Like

Hi @TimBall

Welcome to UiPath community buddy

you can use a move file activity that would move the file or even the folder to the destination you set,
pass the source folder path completely- mean the full path of logs folder in your system and you can find this by pressing the open logs option from execute menu in your studio
image
go there and get the file path and set the destination path as well
One activity can do this buddy
for more info on this activity
https://activities.uipath.com/docs/move-file
Cheers

Hi Tim,
you can create value per bot in orch and then you can use it so you can hard code the path
C:\Users<user name>\AppData\Local\UiPath\Logs

OR Try this

directory.getfiles( Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.ApplicationData),“UiPath”,“Logs”)

1 Like