Lister le contenu d'un dossier
Bonjour à tous,
Je m'y connait très peu en VBSCRIPT et on me demande de lister le contenu d'un répertoire dans une page HTML. J'ai essayé plusieurs manière mais tout à été peu concluant: rien ne s'affiche. J'ai repris le code de microsoft (http://support.microsoft.com/kb/q218606) mais rien ne s'affiche pour autant Est ce que quelqu'un aurait une idée?
Je vous montre le code on sait jamais :D
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| <%@LANGUAGE="VBSCRIPT"%>
<%
Option Explicit
Dim strDocsPath, strDocsPhysicalPath
Dim objFSO, objFolder, objFiles, objFile
Dim strName, strFile, strType, lngSize
' NOTE: set the following line to the folder to display
strDocsPath = "C:\"
' map the folder to a physical path
strDocsPhysicalPath = Server.MapPath(strDocsPath)
' create a system file object
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
' create an object for the folder
Set objFolder = objFSO.GetFolder(strDocsPhysicalPath)
%>
<html>
<head>
<title>Table Of Contents</title>
</head>
<body>
<h1 align="center">Table Of Contents</h1>
<h4>Please choose the Document to view.</h4>
<ul>
<%
' create a files collection
Set objFiles = objFolder.Files
' step through the files collection
For Each objFile in objFiles
' get a file's name
strName = objFile.Name
' make it lowercase for the URL
strFile = Lcase(strName)
' get the file's type
strType = objFile.Type
' make the name a title for display
strName = MakeTitle(strName)
' get the file size in KB
lngSize = objFile.Size\1024
' output the filename and URL
Response.Write "<li><a href=""" & strDocsPath & "/" & strFile & """>" & strName & "</a><br>"
' output the file's size and type
Response.Write "<em>(" & lngSize & "KB " & strType & ")</em></li>" & vbCrLf
Next
' this function drops the extension from a file
Function MakeTitle(strTemp)
If InStrRev(strTemp,".") Then
strTemp = Left(strTemp,InStrRev(strTemp,".")-1)
End If
MakeTitle = strTemp
End Function
%>
</ul>
</body>
</html> |
Merci d'avance.