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%\System\web32.dll
while the consumer code is expecting it in the format
C:\Program Files\Common Files\System\web32.dll
How can I resolve such directory path in .net code?
Open project properties by right clicking on the project in the solution explorer and select Properties. This will open properties page. Click on Debug tab and you will see Environment Variables as shown below. You may change the value as per your need.
The GetEnvironmentVariable(String) method retrieves an environment variable from the environment block of the current process only. It is equivalent to calling the GetEnvironmentVariable(String, EnvironmentVariableTarget) method with a target value of EnvironmentVariableTarget.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With