VirtualDirectoryCollection.Item[String] Property

Definition

Gets a virtual directory with the specified key in the collection.

public:
 property Microsoft::Web::Administration::VirtualDirectory ^ default[System::String ^] { Microsoft::Web::Administration::VirtualDirectory ^ get(System::String ^ path); };
public Microsoft.Web.Administration.VirtualDirectory this[string path] { get; }
member this.Item(string) : Microsoft.Web.Administration.VirtualDirectory
Default Public ReadOnly Property Item(path As String) As VirtualDirectory

Parameters

path
String

The path of the virtual directory to retrieve from the virtual directory collection.

Property Value

The virtual directory with the specified key in the VirtualDirectoryCollection object.

Examples

The following example creates a new virtual directory under a new application. The example then uses the indexer and the name of the virtual directory to retrieve the instance and display the virtual directory path.

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

namespace AdministrationSnippets
{
    class AdministrationVirtualDirectoryCollectionItem2
    {
        public void VirtualDirectoryAddGet()
        {
            ServerManager manager = new ServerManager();
            Site defaultSite = manager.Sites["Default Web Site"];

            ApplicationPool blogPool = manager.ApplicationPools.Add("PhotoApplicationPool");
            Application app = defaultSite.Applications.Add("/photo", @"C:\inetpub\wwwroot\photo");
            app.VirtualDirectories.Add("/family", @"C:\photos\family");
            manager.CommitChanges();
string path = 
    defaultSite.Applications[@"/photo"].VirtualDirectories[@"/family"].Path;
Console.WriteLine("Family photo path is: {0}", path );
        }
    }
}

Remarks

The Path property of a virtual directory corresponds to the key for a virtual directory in the VirtualDirectoryCollection object.

Applies to