Replace("*", username)

Hello all,

I hope everyone are doing well.

I would like to know how I can replace a character in a path every time this character appears.

For example I want to replace the asterisk for the username in order to get the user name of the user where the bot is going to be run.
I know I can do this ;

username = System.Environment.UserName
filePath=“C:\Users*\Desktop\Test\Test.txt”
filePath.Replace("*", username) =“C:\Users\DJohn\Desktop\Test\Test.txt”

However, I would like to perform only one time for all the activities in the flow which contains an asterisk on the path

Anyone has any idea

grafik

why are you doing that, i think is better to replace directly C:\Users\"+Environment.UserName+"\Desktop\Test\Test.txt

regards!

You could also use “Get Environment Folder” activity if you wanted to reference the current users desktop as a variable:
image

You know that it’ll always start with “C:\Users” and end with “\Desktop\Test\Test.txt” so just do…

“C:\Users\” + System.Environment.Username + “\Desktop\Test\Test.txt”

in addition to above also have a look at following:
grafik

1 Like

Oooohhhh I never knew about those.

There are some very useful ones here! Oddly, the Downloads folder isn’t one of them.

1 Like