Share via


VirtualDirectory.PhysicalPath Property

Definition

Gets or sets the physical location of the virtual directory to use.

public:
 property System::String ^ PhysicalPath { System::String ^ get(); void set(System::String ^ value); };
public string PhysicalPath { get; set; }
member this.PhysicalPath : string with get, set
Public Property PhysicalPath As String

Property Value

The physical location path of which the virtual directory maps.

Examples

The following example demonstrates how to set the PhysicalPath property of a virtual directory.


using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
using Microsoft.Web.Management;
using Microsoft.Web.Management.Client;

namespace AdministrationSnippets
{
    public class AdministrationVirtualDirectory
    {
        // Creates a new virtual directory, retrieves the configuration,
        // then changes the Path and PhysicalPath
        public void SetPathAndPhysicalPath()
        {
            // Create a new application and update the configuration system
            ServerManager manager = new ServerManager();
            Site defaultSite = manager.Sites["Default Web Site"];
            Application reports =
                defaultSite.Applications.Add("/reports", @"C:\inetpub\reports");
            manager.CommitChanges();
            
            
            // Read the data back from the updated configuration system, 
            // then modify the Path and Physical Path.
            reports = manager.Sites["Default Web Site"].Applications["/reports"];
            VirtualDirectory reportDir = reports.VirtualDirectories[0];
            reportDir.Path = "/private_reports";
            reportDir.PhysicalPath = @"C:\inetpub\secure\reports";
            manager.CommitChanges();
        }
    }
}

Remarks

This path may be a UNC path. However, credentials are required if you are delegating administration of this directory to a user who is not a member of the local Administrators group on the Web server.

Applies to