One way to get it is: -
var actualPath = Environment.ExpandEnvironmentVariables(yourpathtoconvert);
ex: - var actualPath = Environment.ExpandEnvironmentVariables(@"%SystemDrive%\Inetpub\wwwroot\");
Link
This will help you convert any of the environment variables into its actual values ββas they are configured in the operating system.
Another way is probably less useful, since you will need to extract them and use
Environment.GetEnvironmentVariable("ExactEnvVariableName");
ex: - Environment.GetEnvironmentVariable("SystemDrive");
PSL
source share