这是以前人写的一个文件.看看你用不用得上:
<%@LANGUAGE="VBSCRIPT"%>
<html>
<head>
<META
http-equiv=Content-type
content=text/html;charset=GB2312>
</head>
<body
bgcolor='#B6CFB6'>
<%
on
error
resume
next
'这部份用于认证用户权限
'if
Request.Cookies("myweb")("username")=""
then
' Response.Redirect("../logon_tmp.asp?gotov=mh/index.asp")
' Response.End
'else
' Response.Write
"<center>您好,"
&
Request.Cookies("myweb")("username")
&"<br><a
href='../news/UserEdit.asp'>修改资料</a> <a
href='../news/logout.asp?gobak=1'>退出登陆</a></center><br><br><br>"
'end
if
'根据需要设置参数
PageCount=15'
每页显示的个数
strFileName="index.asp"
strdir="../"'
设置显示的初始目录
Function
IsObjInstalled(strClassString)
'测试控件有没有安装的函数,此页用于测试FSO,见后面调用
On
Error
Resume
Next
IsObjInstalled
=
False
Err
=
0
Dim
xTestObj
Set
xTestObj
=
Server.CreateObject(strClassString)
If
0
=
Err
Then
IsObjInstalled
=
True
Set
xTestObj
=
Nothing
Err
=
0
End
Function
if
request("page")<>""
then
currentPage=cint(request("page"))
'当前页码
else
currentPage=1
end
if
MaxPerPage=PageCount
UploadDir
=
request("parentPath")
'要列出的文件夹名称,相对于此页面文件所在根目录来说
if
UploadDir=""
then
UploadDir=strdir
TruePath=Server.MapPath(UploadDir)
'获得全路径
If
not
IsObjInstalled("Scripting.FileSystemObject")
Then
'测试是否支持FSO
Response.Write
"<b><font
color=red>你的服务器不支持
FSO(Scripting.FileSystemObject)!
不能使用本功能</font></b>"
Else
set
fso=CreateObject("Scripting.FileSystemObject")
'如果支持FSO就创建FSO对象
if
fso.FolderExists(TruePath)then'如果指定的目录存在就计算目录中文件数量,并列举文件
FileCount=0
subFolderCount=0
TotleSize=0
TotleSize2=0
Set
theFolder=fso.GetFolder(TruePath)
For
Each
thesubfolder
in
theFolder.SubFolders'计算子文件夹的个数
subFolderCount=subFolderCount+1
Next
For
Each
theFile
In
theFolder.Files'
计算文件的个数
FileCount=FileCount+1
'计算总文件数
TotleSize2=TotleSize2+theFile.Size
'计算总文件容量
next
totalPut=FileCount+subFolderCount
'总文件、子目录数
if
currentpage<1
then
currentpage=1
end
if
if
(currentpage-1)*MaxPerPage>totalput
then
'计算当前页码
if
(totalPut
mod
MaxPerPage)=0
then
currentpage=
totalPut
\
MaxPerPage
else
currentpage=
totalPut
\
MaxPerPage
+
1
end
if
end
if
if
currentPage=1
then
showContent
'罗列文件
showpage2
strFileName,totalput,MaxPerPage,UploadDir
response.write
"<br/><div
align='center'>本页共显示
<b>"
&
FileCount
&
"</b>
个文件,占用
<b>"
&
TotleSize\1024
&
"</b>
K</div>"
else
if
(currentPage-1)*MaxPerPage<totalPut
then
showContent
showpage2
strFileName,totalput,MaxPerPage,UploadDir
response.write
"<br/><div
align='center'>本页共显示
<b>"
&
FileCount
&
"</b>
个文件,占用
<b>"
&
TotleSize\1024
&
"</b>
K</div>"
else
currentPage=1
showContent
showpage2
strFileName,totalput,MaxPerPage,UploadDir
response.write
"<br/><div
align='center'>本页共显示
<b>"
&
FileCount
&
"</b>
个文件,占用
<b>"
&
TotleSize\1024
&
"</b>
K</div>"
end
if
end
if
else
response.write
"找不到文件夹!可能是配置有误!"
end
if
end
if
sub
showContent()'罗列文件及子文件夹的子过程
dim
c
FileCount=0
TotleSize=0
%>
<form
action=""
name="form1"
method="post">
<table
width="95%"
border="1"
cellspacing="0"
cellpadding="3"
align="center"
bordercolorlight="#ECEEE4"
bordercolordark="#CCCABC">
<tr>
<td
colspan="5"
align="center"
height="30"
background="image/tablebg.gif"><b>上
传
文
件
管
理</b>
</td>
</tr>
<tr
align="center"
valign="middle">
<td
height="25">文件名</td>
<td
height="25">文件大小</td>
<td
height="25">文件类型</td>
<td
height="25">最后修改时间</td>
</tr>
<%
if
UploadDir<>strdir
then
%>
<tr
align="center"
valign="middle">
<td
height="25"><a
href="<%=strFileName%>?page=1&parentPath=<%=left(UploadDir,instrrev(UploadDir,"/")-1)%>"><strong>..</strong></a>(返回上级目录)</td>
<td
height="25"></td>
<td
height="25"> </td>
<td
height="25"> </td>
</tr>
<%
end
if
For
Each
thesubfolder
in
theFolder.SubFolders
'罗列子文件夹的代码
c=c+1
if
FileCount>=MaxPerPage
then
exit
for
elseif
c>MaxPerPage*(CurrentPage-1)
then
%>
<tr
align="center"
valign="middle">
<td
height="25"><a
href="<%=strFileName%>?page=1&parentPath=<%=(UploadDir
&
"/"
&
thesubfolder.Name)%>"><strong>
<%
ba=split(thesubfolder.Name,".")
response.write
ba(0)
%>
</strong></a></td>
<td
height="25"> </td>
<td
height="25"> </td>
<td
height="25"> </td>
</tr>
<%
FileCount=FileCount+1
end
if
Next
For
Each
theFile
In
theFolder.Files'罗列文件的代码
c=c+1
if
FileCount>=MaxPerPage
then
exit
for
elseif
c>MaxPerPage*(CurrentPage-1)
then
%>
<tr
align="center"
valign="middle">
<td
height="25"><a
href="<%=(UploadDir
&
"/"
&
theFile.Name)%>"
target="_blank"><strong>
<%
ba=split(theFile.Name,".")
response.write
ba(0)
%>
</strong></a></td>
<td
height="25"><%=theFile.size%>字节</td>
<td
height="25"><%=theFile.type%></td>
<td
height="25"><%=theFile.DateLastModified%></td>
</tr>
<%
FileCount=FileCount+1
TotleSize=TotleSize+theFile.Size
end
if
Next
%>
</table>
</form>
<%
end
sub
sub
showpage2(sfilename,totalnumber,maxperpage,parentPath)'写页脚
dim
n,
i,strTemp
if
totalnumber
mod
maxperpage=0
then
n=
totalnumber
\
maxperpage
else
n=
totalnumber
\
maxperpage+1
end
if
strTemp=
"<table
align='center'><form
name='showpages'
method='Post'
action='"
&
sfilename
&
"'><tr><td>"
strTemp=strTemp
&
"共
<b>"
&
totalnumber
&
"</b>
个文件及子目录,占用
<b>"
&
TotleSize2\1024
&
"</b>
K "
if
CurrentPage<2
then
strTemp=strTemp
&
"首页
上一页 "
else
strTemp=strTemp
&
"<a
href='"
&
sfilename
&
"?page=1&parentPath="&
parentPath
&"'>首页</a> "
strTemp=strTemp
&
"<a
href='"
&
sfilename
&
"?page="
&
(CurrentPage-1)
&
"&parentPath="&
parentPath
&"'>上一页</a> "
end
if
if
n-currentpage<1
then
strTemp=strTemp
&
"下一页
尾页"
else
strTemp=strTemp
&
"<a
href='"
&
sfilename
&
"?page="
&
(CurrentPage+1)
&
"&parentPath="&
parentPath
&"'>下一页</a> "
strTemp=strTemp
&
"<a
href='"
&
sfilename
&
"?page="
&
n
&
"&parentPath="&
parentPath
&"'>尾页</a>"
end
if
strTemp=strTemp
&
" 页次:<strong><font
color=red>"
&
CurrentPage
&
"</font>/"
&
n
&
"</strong>页
"
strTemp=strTemp
&
" <b>"
&
maxperpage
&
"</b>"
&
"个文件/页"
strTemp=strTemp
&
" 转到:<select
name='page'
size='1'
onchange='javascript:submit()'>"
for
i
=
1
to
n
strTemp=strTemp
&
"<option
value='"
&
i
&
"'"
if
cint(CurrentPage)=cint(i)
then
strTemp=strTemp
&
"
selected
"
strTemp=strTemp
&
">第"
&
i
&
"页</option>"
next
strTemp=strTemp
&
"</select>"
strTemp=strTemp
&
"<input
type=hidden
name=parentPath
value="&parentPath&">"
strTemp=strTemp
&
"</td></tr></form></table>"
response.write
strTemp
end
sub
%>
</body>
</html>