<%
aaa="images/" ' ------------文件夹路径
pagesize=3 '--------------每页显示的文件数!
totalpage=1
page=trim(request.querystring("page"))
if page<>"" and isnumeric(page) then
page=fix(page)
else
page=1
end if
Set fs = CreateObject("Scripting.FileSystemObject")
sPathFile=""&aaa&""
Set f = fs.GetFolder(Server.MapPath(sPathFile))
if f.files.count mod pagesize=0 then
totalpage=f.files.count\pagesize
else
totalpage=f.files.count\pagesize+1
end if
if page<1 then
page=1
end if
if page>totalpage then
page=totalpage
end if
i=1
startnum=(page-1)*pagesize%>
<% For Each s_folder in f.subfolders %>'----文件夹循环开始
<%=s_folder.name%>
<% next %>
<% For Each f1 in f.Files
if i>startnum then %>'----文件循环开始
<%= f1.name%><%= f1.size%><%= f1.type%><%= f1.datelastmodified%>
<%
end if
if i>startnum+pagesize then
exit for
end if
i=i+1
next
%>
<%if page>1 then %>'---分页开始
<a href="/?page=1">首页</a>
<% end if %>
<%if page>1 then %>
<a href="?page=<%=page-1%>">上一页</a>
<% end if %>
<% If f.files.count=0 Then %>
此目录下没有文件!
<% Else %>
共<%=f.files.count%>个文件 第<%=page%> / <%=totalpage%>页
<% End If %>
<%if page<totalpage then%>
<a href="?page=<%=page+1%>">下一页</a>
<%end if %>
<%if page<>totalpage then%>
<a href="?page=<%=totalpage%>">尾页</a>
<%end if %>'----分页结束
<% set fs=nothing %>
<%'------------------------删除文件!
If request("action")="del_upfilename" Then
del_upfilename=request("del_upfilename")
set fileobj=server.createobject("scripting.filesystemobject")
if fileobj.FileExists(server.mappath(del_upfilename)) then
fileobj.DeleteFile(server.mappath(del_upfilename))
end if
set fileobj=nothing
response.write "<script language=javascript>alert('删除成功!');location.href('?page="&page&"');</script>"
end if
%>