I have a situation where I need to return a directory path by reading the registry settings. Registry value returns me a path in the format
%CommonProgramFiles%\
You can use the Environment.GetEnvironmentVariable function:
string commonDir = Environment.GetEnvironmentVariable("CommonProgramFiles");
You can then use Path.Combine to append the rest of the path:
string fullPath = Path.Combine(commonDir, "System", "web32.dll");
Another option is to use Environment.ExpandEnvironmentVariables. This will replace all environment variables with their values:
string fullPath = Environment.ExpandEnvironmentVariables("%CommonProgramFiles%\System\web32.dll");
Environment.ExpandEnvironmentVariables. If you control the creation of the registry value, store it as an expandable string in the registry and the registry API will automatically expand it for you.