Information générale
Titre:
Create A Virtual Directory Inside A Virtual Directory In IIS
Versions des environnements
Network:
Windows 2003 Server
I can use the following to create a Virtual Directory under a folder in IIS:
IISAdmin = new System.DirectoryServices.DirectoryEntry("IIS://localhost/W3SVC/" + webSiteNum + "/Root");
VDir = IISAdmin.Children.Add(VDirName, "IIsWebVirtualDir");
webSiteNum is obtained with the following function:
public static string getWebSiteIdentifier(string webSiteName, Label errorMessage)
{
string webSiteIdentifier = "0";
try
{
const string WebServerSchema = "IIsWebServer";
string ServerName = "LocalHost";
DirectoryEntry W3SVC = new DirectoryEntry("IIS://" + ServerName + "/w3svc");
foreach (DirectoryEntry Site in W3SVC.Children)
{
if (Site.SchemaClassName == WebServerSchema)
{
//Response.Write("WebSite Instance ID : " + Site.Name);
foreach (string PropertyName in Site.Properties.PropertyNames)
{
//ListBox1.Items.Add(PropertyName);
//Response.Write(PropertyName);
PropertyValueCollection pvc = Site.Properties[PropertyName];
foreach (object ServerComment in pvc)
{
if (ServerComment.ToString().Trim() == webSiteName.Trim())
{
webSiteIdentifier = Site.Name;
}
}
}
}
}
}
catch (System.Exception ex)
{
errorMessage.Text = ex.Message;
errorMessage.ForeColor = System.Drawing.Color.Red;
webSiteIdentifier = "0";
}
return webSiteIdentifier;
}
However, I would like to create a Virtual Directory inside an existing named Virtual Directory - can anyone help?
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement