虚拟目录问题!急在线等。 打开IIS,点开左边的默认网战,在上边单击右键选择,然后按说明步骤进行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我问的是我用程序建的虚拟目录怎么在IIS中不可见? wideroad不要开玩笑了,我想知道的是如何在程序中建立 大哥们,我现在很郁闷,搞了一天,也没有看到。但是用find的方法却能找到。希望大家指教啊。 to:meetweb(niky)能具体点吗? 你的代码并未包含建虚拟目录的部分呀.我有一段小玩艺, 请笑纳.using System;using System.DirectoryServices;namespace JoeM.Utilites.VirtualDirectory{ /// <summary> /// Summary description for IISManager. /// </summary> public class IISManager { /// <summary> /// Constructor /// </summary> /// <param name="serverName">Name of the IIS Server</param> public IISManager(string serverName) { _serverName = serverName; } /// <summary> /// Default constructor uses localhost as default server /// </summary> public IISManager() { _serverName = "localhost"; } /// <summary> /// Connect to IISServer /// </summary> public void Connect() { try { _iisServer = new DirectoryEntry("IIS://" + _serverName + "/W3SVC/1"); } catch (Exception e) { throw new Exception("Could not connect to: " + _serverName,e); } } /// <summary> /// Create a virtual directory /// </summary> /// <param name="nameDirectory">Name of the new virtual directory</param> /// <param name="realPath">Path of the directory</param> public void CreateVirtualDirectory(string nameDirectory,string realPath) { DirectoryEntry folderRoot = _iisServer.Children.Find("Root",VirDirSchemaName); try { DirectoryEntry newVirDir = folderRoot.Children.Add(nameDirectory,VirDirSchemaName); // Set Properties newVirDir.Properties["AccessRead"].Add(true); newVirDir.Properties["Path"].Add(realPath); // Create a Application newVirDir.Invoke("AppCreate",true); // Save Changes newVirDir.CommitChanges(); folderRoot.CommitChanges(); _iisServer.CommitChanges(); } catch (Exception e) { throw new Exception("Virtual Directory " + nameDirectory + " Already Exists",e); } } #region Properties public string ServerName { get { return _serverName; } set { _serverName = value; } } #endregion public static string VirDirSchemaName = "IIsWebVirtualDir"; #region Private Members private string _serverName; private DirectoryEntry _iisServer; #endregion }} 哦。我自己解决了饿。哈哈代码如下:public void CreateVirtualDirectory(string nameDirectory,string realPath){ DirectoryEntry folderRoot = _iisServer.Children.Find("Root",VirDirSchemaName); try{DirectoryEntry newVirDir = folderRoot.Children.Add(nameDirectory,VirDirSchemaName);newVirDir.CommitChanges();// Set PropertiesnewVirDir.Properties["AccessRead"].Add(true); //newVirDir.Properties["Path"].Add(realPath);newVirDir.Properties["Path"].Value = realPath;// Create a Application: Don't use invoke method//newVirDir.Invoke("AppCreate",true);// Save ChangesnewVirDir.CommitChanges();folderRoot.CommitChanges();_iisServer.CommitChanges();}catch (Exception e){Console.WriteLine(e.Message);throw new Exception("Virtual Directory " + nameDirectory + " Already Exists",e);}} C#控制台 无法输入汉字 求教!!! datagridview中拖动行删除拖动的行在新位置后插入不了 求一个正则表达式,请高手帮忙 无法绑定由多个部分组成的标识符 "System.Data.SqlClient.SqlConnection"。 代码较多,请大虾指点 GDI+画图,可以使用滚轴调整图形的大小! 求C#设计手册一书 ConfigurationUserLevel.None修改配置文件的路径在哪里? 请问:c#中如何清除打印缓冲区? ???请教大家一个算法,用c#,谢谢! *****datalist问题 ArrayList的Add方法出错 线程间的通信该怎么做?
不要开玩笑了,我想知道的是如何在程序中建立
能具体点吗?
我有一段小玩艺, 请笑纳.using System;
using System.DirectoryServices;namespace JoeM.Utilites.VirtualDirectory
{
/// <summary>
/// Summary description for IISManager.
/// </summary>
public class IISManager
{
/// <summary>
/// Constructor
/// </summary>
/// <param name="serverName">Name of the IIS Server</param>
public IISManager(string serverName)
{
_serverName = serverName;
}
/// <summary>
/// Default constructor uses localhost as default server
/// </summary>
public IISManager()
{
_serverName = "localhost";
}
/// <summary>
/// Connect to IISServer
/// </summary>
public void Connect()
{
try
{
_iisServer = new DirectoryEntry("IIS://" + _serverName + "/W3SVC/1");
}
catch (Exception e)
{
throw new Exception("Could not connect to: " + _serverName,e);
}
} /// <summary>
/// Create a virtual directory
/// </summary>
/// <param name="nameDirectory">Name of the new virtual directory</param>
/// <param name="realPath">Path of the directory</param>
public void CreateVirtualDirectory(string nameDirectory,string realPath)
{
DirectoryEntry folderRoot = _iisServer.Children.Find("Root",VirDirSchemaName);
try
{
DirectoryEntry newVirDir = folderRoot.Children.Add(nameDirectory,VirDirSchemaName);
// Set Properties
newVirDir.Properties["AccessRead"].Add(true);
newVirDir.Properties["Path"].Add(realPath);
// Create a Application
newVirDir.Invoke("AppCreate",true);
// Save Changes
newVirDir.CommitChanges();
folderRoot.CommitChanges();
_iisServer.CommitChanges();
}
catch (Exception e)
{
throw new Exception("Virtual Directory " + nameDirectory + " Already Exists",e);
}
}
#region Properties
public string ServerName
{
get
{
return _serverName;
}
set
{
_serverName = value;
}
}
#endregion
public static string VirDirSchemaName = "IIsWebVirtualDir";
#region Private Members
private string _serverName;
private DirectoryEntry _iisServer;
#endregion
}
}
public void CreateVirtualDirectory(string nameDirectory,string realPath)
{
DirectoryEntry folderRoot = _iisServer.Children.Find("Root",VirDirSchemaName);
try
{
DirectoryEntry newVirDir = folderRoot.Children.Add(nameDirectory,VirDirSchemaName);
newVirDir.CommitChanges();// Set Properties
newVirDir.Properties["AccessRead"].Add(true);
//newVirDir.Properties["Path"].Add(realPath);
newVirDir.Properties["Path"].Value = realPath;// Create a Application: Don't use invoke method
//newVirDir.Invoke("AppCreate",true);
// Save Changes
newVirDir.CommitChanges();
folderRoot.CommitChanges();
_iisServer.CommitChanges();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw new Exception("Virtual Directory " + nameDirectory + " Already Exists",e);
}
}