Alguien sabe como se puede acceder a iis y obtener un listado de los directorios virtuales existentes en mi maquina desde WinForm.
Se agradecería un ejemplito, por que en inet no veo nada
| ||||
Puedes ocupar la siguiente clase http://www.codeproject.com/csharp/virtualdir.asp Es para crear directorios virtuales pero solo basta con modificar algun para de cosas para obtener los directorios. Si lo logras sería bueno que publicaras el ejemplo para que le sirva a los demás.. Si se te complica espero darme un tiempo para crearlo porque ahorita ando con un buen de chamba.... pero esa es otra historia... jeje Salu2
__________________ Nadie roba nada ya que en la vida todo se paga . . . Exentrit - Soluciones SharePoint & Net |
| ||||
he encontrado en la web este codigo visual basic scripting host que lo hace: OPTION EXPLICIT DIM CRLF, TAB,LF DIM strServer DIM objWebService TAB = CHR( 9 ) CRLF = CHR( 13 ) & CHR( 10 ) LF = CHR( 10 ) IF WScript.Arguments.Length = 1 THEN strServer = WScript.Arguments( 0 ) ELSE strServer = "localhost" END IF WScript.Echo "Enumerating websites on " & strServer & CRLF SET objWebService = GetObject( "IIS://" & strServer & "/W3SVC" ) EnumWebsites objWebService SUB EnumVirtualDirectories( objWebRoot ) DIM objVirDir,objDIR FOR each objVirDir IN objWebRoot IF objVirDir.Class = "IIsWebVirtualDir" THEN WScript.Echo "ADSPath = "&objVirDir.ADsPath&CRLF&_ "Path = "&objVirDir.Path & TAB & LF EnumVirtualDirectories( objVirDir ) WScript.Echo CRLF END IF 'IF objVirDir.Class = "IIsWebDirectory" THEN ' WScript.Echo "ADSPath = "&objVirDir.ADSPath&CRLF&_ ' "Path = "&objVirDir.Path&CRLF ' EnumVirtualDirectories( objVirDir ) 'END IF NEXT END SUB SUB EnumWebsites( objWebService ) DIM objWebServer, strBindings DIM objWebRoot FOR EACH objWebServer IN objWebService IF objWebserver.Class = "IIsWebServer" THEN WScript.Echo _ "Site ID = " & objWebserver.Name & CRLF & _ "Comment = """ & objWebServer.ServerComment & """ " & CRLF & _ "State = " & State2Desc( objWebserver.ServerState ) & CRLF & _ "LogDir = " & objWebServer.LogFileDirectory & CRLF &_ "ADsPath = " & objWebServer.ADsPath & CRLF SET objWebRoot=objWebserver.GetObject("IIsWebVirtualDi r","ROOT") IF objWebRoot.Class="IIsWebVirtualDir" THEN WScript.Echo "PATH = " & objWebRoot.Path &CRLF EnumVirtualDirectories ( objWebRoot ) END IF SET objWebRoot = NOTHING ' Enumerate the HTTP bindings (ServerBindings) and ' SSL bindings (SecureBindings) strBindings = EnumBindings( objWebServer.ServerBindings ) & _ EnumBindings( objWebServer.SecureBindings ) IF NOT strBindings = "" THEN WScript.Echo "IP Address" & TAB & _ "Port" & TAB & _ "Host" & CRLF & _ strBindings END IF END IF NEXT END SUB FUNCTION EnumBindings( objBindingList ) DIM i, strIP, strPort, strHost DIM reBinding, reMatch, reMatches SET reBinding = NEW RegExp reBinding.Pattern = "([^:]*):([^:]*):(.*)" FOR i = LBOUND( objBindingList ) TO UBOUND( objBindingList ) ' objBindingList( i ) is a string looking like IP:Port:Host SET reMatches = reBinding.Execute( objBindingList( i ) ) FOR EACH reMatch IN reMatches strIP = reMatch.SubMatches( 0 ) strPort = reMatch.SubMatches( 1 ) strHost = reMatch.SubMatches( 2 ) ' Do some pretty processing IF strIP = "" THEN strIP = "All Unassigned" IF strHost = "" THEN strHost = "*" IF LEN( strIP ) < 8 THEN strIP = strIP & TAB EnumBindings = EnumBindings & _ strIP & TAB & _ strPort & TAB & _ strHost & TAB & _ "" NEXT EnumBindings = EnumBindings & CRLF NEXT END FUNCTION FUNCTION State2Desc( nState ) SELECT CASE nState CASE 1 State2Desc = "Starting (MD_SERVER_STATE_STARTING)" CASE 2 State2Desc = "Started (MD_SERVER_STATE_STARTED)" CASE 3 State2Desc = "Stopping (MD_SERVER_STATE_STOPPING)" CASE 4 State2Desc = "Stopped (MD_SERVER_STATE_STOPPED)" CASE 5 State2Desc = "Pausing (MD_SERVER_STATE_PAUSING)" CASE 6 State2Desc = "Paused (MD_SERVER_STATE_PAUSED)" CASE 7 State2Desc = "Continuing (MD_SERVER_STATE_CONTINUING)" CASE ELSE State2Desc = "Unknown state" END SELECT END FUNCTION
__________________ Salu2 :pensando: |