Dynamic file path in Config file


could you please advise how to create a dynamic path in a Config file, so that robot takes from there the correct path no matter what computer name is? For example if robot runs on computer CMXXX, the path would be “C:\Users\CMXXX\Desktop”, if on computer ABXXX, the path would be “C:\Users\ABXXX\Desktop”. I know that this is possible by assigning the value directly to variable, like “C:\Users”+environment.username+“CMAZP\Desktop” but how to create the same in a Config file and refer to it?

Thank you




Can you try System.Environment.ExpandEnvironmentVariables method?

For eaxmple,
System.Environment.ExpandEnvironmentVariables("%USERPROFILE%") returns c:\Users\[UserName]
System.Environment.ExpandEnvironmentVariables("%COMPUTERNAME%") returns your computer name.

So you can write %EnvironmentVariable% in your config file, then extract it using this method.




You can work with String Format also

Check the variable

Mark as solution if this helps


1 Like

Thank you guys!

1 Like

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