Application.Path Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the relative associated with the application.
public:
property System::String ^ Path { System::String ^ get(); void set(System::String ^ value); };
public string Path { get; set; }
member this.Path : string with get, set
Public Property Path As String
Property Value
The relative path the application is bound to.
Examples
The following example displays the relative path for the applications configured under the default Web site.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
using Microsoft.Web.Management;
namespace AdministrationSnippets
{
public class AdministrationApplicationPath
{
// Writes out the application paths found under the default Web site.
public void GetPath()
{
ServerManager manager = new ServerManager();
Site defaultSite = manager.Sites["Default Web Site"];
foreach (Application app in defaultSite.Applications)
{
Console.WriteLine(
"Found application with the following path: {0}",
app.Path);
}
}
}
}
The following example creates a new application and then uses the Path property to change the relative path of the application, and then uses the PhysicalPath property to change the physical path of the application.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Administration;
using Microsoft.Web.Management;
namespace AdministrationSnippets
{
public class AdministrationApplicationPath
{
// Creates an application and sets its associated path.
public void SetPath()
{
// Create a new application.
ServerManager manager = new ServerManager();
Site defaultSite = manager.Sites["Default Web Site"];
defaultSite.Applications.Add("/blogs1", @"C:\inetpub\wwwroot\");
manager.CommitChanges();
// Change the relative path.
manager = new ServerManager();
defaultSite = manager.Sites["Default Web Site"];
defaultSite.Applications["/blogs1"].Path = @"/blogs2";
manager.CommitChanges();
// Change the physical path.
manager = new ServerManager();
defaultSite = manager.Sites["Default Web Site"];
defaultSite.Applications["/blogs2"].VirtualDirectories["/"].PhysicalPath
= @"C:\inetpub\wwwroot\blogs";
manager.CommitChanges();
}
}
}
Remarks
This value represents the path of the root of the application.