Pregunta: | 3501 - COMO DETERMINAR QUE ARCHIVOS Y CARPETAS HAY |
Autor: | Xavi Vila |
Como puedo saber que archivos y/o carpetas (directorios) hay actualmente en mi servidor. Gracias. |
Respuesta: | Xavi |
Esta funcion, devuelve un array con los archivos de tu directorio en el servidor. Function MostrarListaArchivos() Dim fso, f, f1, fc dim x,s s=array() x=0 Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.Getfolder(server.mappath("/")) Set fc = f.Files For Each f1 in fc if ucase(right(f1.name,4))=".HTM" or ucase(right(f1.name,5))=".HTML" then redim preserve s(x) s(x)= f1.name x=x+1 end if Next MostrarListaArchivos = s End Function y este un array de los directorios de tu servidor. Function MostrarListaCarpetas() Dim fso, f, f1, sf dim x,s s=array() x=0 Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder(server.mappath("/")) Set sf = f.SubFolders For Each f1 in sf redim preserve s(x) s(x)= f1.name x=x+1 Next MostrarListaCarpetas = s End Function Para llamar a cualquier funcion. a=nombrefuncion Para visualizar los datos for i=0 to ubound(a) Response.Write(a(i) & "<BR>") next |