programming-examples/asp/More_Code_Snippets/This shows how to display the contents of a directory that the script is in.asp

33 lines
1.0 KiB
Plaintext
Raw Permalink Normal View History

2019-11-18 14:25:58 +01:00
<p align="left"><b>Directory details</b></p>
<br>
<%
Dim strPath , strPhysical
strPath = Request.ServerVariables("SCRIPT_NAME")
strPhysical = Server.MapPath(strPath)
Dim objFSO , objFile , objFileItem , objFolder , objFolderFiles
' create an instance of the FileSystemObject
set objFSO = CreateObject("Scripting.FileSystemObject")
' get a file object that corresponds to the file that we have the path for
set objFile = objFSO.GetFile(strPhysical)
'return a reference to a folder object that represents the folder the file resides in
set objFolder = objFile.ParentFolder
set objFolderFiles = objFolder.Files
%>
<TABLE CELLPADDING = 3 CELLSPACING = 2>
<TR>
<TH>File Name</TH>
<TH>File Size</TH>
<TH>Last modified</TH>
</TR>
<%
For Each objFileItem In objFolderFiles
Response.Write "<TR><TD>"
Response.Write objFileItem.Name
Response.Write "</TD><TD>"
Response.Write objFileItem.Size
Response.Write "</TD><TD>"
Response.Write objFileItem.DateLastModified
Response.Write "</TD></TR>"
Next
%>
</TABLE>