namespace test
{
public class test
{
private DirectoryEntry _iisServer;
public ConfigSetup()
{
}
private void Connect()
{
try
{
_iisServer = new DirectoryEntry("IIS://" + "localhost" + "/W3SVC/1");
}
catch (Exception e)
{
throw new Exception("Could not connect to: " + "localhost",e);
}
}
public string GetWatchPath()
{
string WatchPath;
Connect();
DirectoryEntry folderRoot = _iisServer.Children.Find("Root","IIsWebVirtualDir");
WatchPath = folderRoot.Properties["Path"].Value.ToString() + "\\CloneDB\\ExportFiles";
return WatchPath;
}
}
}
{
public class test
{
private DirectoryEntry _iisServer;
public ConfigSetup()
{
}
private void Connect()
{
try
{
_iisServer = new DirectoryEntry("IIS://" + "localhost" + "/W3SVC/1");
}
catch (Exception e)
{
throw new Exception("Could not connect to: " + "localhost",e);
}
}
public string GetWatchPath()
{
string WatchPath;
Connect();
DirectoryEntry folderRoot = _iisServer.Children.Find("Root","IIsWebVirtualDir");
WatchPath = folderRoot.Properties["Path"].Value.ToString() + "\\CloneDB\\ExportFiles";
return WatchPath;
}
}
}
获得站点根目录绝对地址
Server.MapPath("/myweb")获得myweb虚拟目录的绝对地址