帮我写一个目录浏览程序(asp)

2025年03月23日 12:14
有1个网友回答
网友(1):

<%@ LANGUAGE="VBSCRIPT" %>

<%

Dim sMapPath,strUrl
strUrl=request("ur")
response.write strurl
if strUrl<>"" then

sMapPath=server.MapPath(strUrl)
else

sMapPath = "e:\"
end if
%>


File Viewer












<%

'File System Object
Dim objFSO
'File Object
Dim objFile
'Folder Object
Dim objFolder
'String To Store The Real Path

'Create File System Object To Get list of files
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get The path For the web page and its dir.
'change this setting To view different directories

'Set the object folder To the mapped path
Set objFolder = objFSO.GetFolder(sMapPath)
'For Each file In the folder
For Each objFile In objFolder.Files
%>







<%
Next
%>


输入目录的名称


   
Title Size Date

">
<%
'write the files name
Response.Write objFile.Name
%>




<%
'We will format the file size so it looks pretty
If objFile.Size <1024 Then
Response.Write objFile.Size & " Bytes"
ElseIf objFile.Size < 1048576 Then
Response.Write Round(objFile.Size / 1024.1) & " KB"
Else
Response.Write Round((objFile.Size/1024)/1024.1) & " MB"
End If
%>


<% 'the files Date
Response.Write objFile.DateLastModified
%>