I am using the Web Deploy API
to deploy a web site programatically . Before the Deploy, I take a back up of the files. I get the physical path of the files by using the 'ServerManager'
Class.
The issue is the physical path returned is %SystemDrive%\Inetpub\wwwroot\<MyApp>
.
How do I convert this to a fully qualified path so that I can back it up?
One way you can get it is by using:-
var actualPath = Environment.ExpandEnvironmentVariables(yourpathtoconvert);
ex:- var actualPath = Environment.ExpandEnvironmentVariables(@"%SystemDrive%\Inetpub\wwwroot\");
Reference
This will help you convert any of the environment variables to its actual values as configured in the Operating System.
Another way probably is less helpful as you would need to extract them out and use
Environment.GetEnvironmentVariable("ExactEnvVariableName");
ex:- Environment.GetEnvironmentVariable("SystemDrive");
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