Application.Path Propriété

Définition

Obtient ou définit le relatif associé à l’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

Valeur de propriété

Chemin d’accès relatif à l’application.

Exemples

L’exemple suivant montre comment afficher le chemin relatif des applications configurées sous le site Web par défaut.

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);
    }
}
    }
}

L’exemple suivant crée une application, puis utilise la Path propriété pour modifier le chemin d’accès relatif de l’application, puis utilise la PhysicalPath propriété pour modifier le chemin physique de l’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();
}
    }
}

Remarques

Cette valeur représente le chemin de la racine de l’application.

S’applique à