10

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?

4

1 回答 1

21

获得它的一种方法是使用:-

var actualPath = Environment.ExpandEnvironmentVariables(yourpathtoconvert);

前任:- var actualPath = Environment.ExpandEnvironmentVariables(@"%SystemDrive%\Inetpub\wwwroot\");

参考

这将帮助您将任何环境变量转换为其在操作系统中配置的实际值。

另一种方法可能不太有用,因为您需要将它们提取出来并使用

Environment.GetEnvironmentVariable("ExactEnvVariableName");

前任:-Environment.GetEnvironmentVariable("SystemDrive");

于 2013-04-30T00:18:46.223 回答