VirtualDirectory.Path 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置虚拟目录相对于其父目录的虚拟路径。
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
属性值
虚拟目录的相对虚拟路径。
示例
以下示例演示如何设置 Path 虚拟目录的 属性。
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();
}
}
}
注解
设置此属性时,路径不得包含 类的 InvalidVirtualDirectoryPathCharactersVirtualDirectoryCollection 属性中的任何字符。 还可以使用 path
方法的 参数 Add 设置此属性的值。