user1240679
user1240679

Reputation: 6979

Expand the %system% directories to full path

In my program, I am getting the path of the default website in IIS through the following code:

ServerManager manager = new ServerManager();
string path = manager.Sites["Default Web Site"].Applications["/"].VirtualDirectories["/"].PhysicalPath;

path = %ystemdrive%\inetpub\wwwroot

Path.GetFullPath doesn't look like appropriate thing for this. How do I get the full path from the above, which actually is C:\inetpub\wwwroot ?

Upvotes: 1

Views: 121

Answers (2)

ionden
ionden

Reputation: 12776

You could use this:

Environment.ExpandEnvironmentVariables(path);

Upvotes: 1

marsch
marsch

Reputation: 33

Just use System.Environment.ExpandEnvironmentVariables()

Also see MSDN.

Upvotes: 1

Related Questions