charles

charles

  • NA
  • 13
  • 0

IIS Virtual Directories

Jul 16 2008 4:01 PM

Scenario is that I need to see if a vd already exists on my system. If it does not I need it to continue on, if it does, then return. Here is the code that I have:

[code]

try

{

string _sName = "localhost";

DirectoryEntry iisServer = new DirectoryEntry("IIS://" + _sName + "/W3SVC/1/Root");

foreach (DirectoryEntry d in iisServer.Children)

{

if (d.Name != "ReportServer")

{

Process p = Process.Start(_InstallEnv.dslShare + @"\Other\AutoIt\Scripts\Exe\sqlsvr_rpt_cnfg.exe");

p.WaitForExit();

p.Close();

}

}

}

catch (Exception ex)

{

response.Error = ex.Message;

response.StackTrace = ex.StackTrace;

response.Status = InstallStatus.FAILED;

}

return response;

[/code]

The issue is that i do not need a foreach loop. I need to loop through the vd's until it finds my direcotry or hits the end of the list. If my vd is found, then return, if not, then install. What am I missing to get this to find my directory?

Chuck