<HTML>
<HEAD><TITLE>文件夹内容</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</HEAD>
<BODY>
<style type="text/css">
.filelist{ clear:both; font-size:12px}
.filelist ul li{list-style:none;float:left; width:180px;}
#filename{ width:400px}
</style>
<%
action=request("action")
filename=request("filename")
foldername=request("foldername")
filePath=request("filePath")
folderPath=request("folderPath")
select case action
case ""
folderPath=server.MapPath("/upfile")
call getfloder(folderPath)
Case "delfile"
dim fs
Set fs=Server.CreateObject("Scripting.FileSystemObject")
'filepath=server.MapPath(filename)
if fs.FileExists(filePath) then
fs.DeleteFile(filepath)
end if
set fs=nothing
call MsgBox("文件删除成功!","Back","")
response.End()
Case "openfile"
'foldername=".\"&foldername
'response.Write server.MapPath(foldername)
'response.End()
call getfloder(folderPath)
end select
%>
<%
'文件夹遍历函数
function getfloder(filename)
dim filepath,fso,fileobj,fsofolders,fsofile,folder,file,allFiles,folder1
response.Write("<div class='filelist'><ul><li >文件夹或文件</li><li id='filename'>文件位置</li><li>最后修改时间</li><li>操作</li></ul></div>")
response.Write "<br/><hr/>"
set fs= server.CreateObject("scripting.FileSystemObject")
'set fileobj= fs.GetFolder(server.MapPath(filename))
response.Write "当前所在文件夹:"&Right(folderPath,Len(folderPath)-Instr(folderPath,"\upfile"))
set fileobj= fs.GetFolder(folderPath)
set subfolders=fileobj.SubFolders
Set allFiles = fileobj.files
For Each folder in subfolders
response.Write("<div class='filelist'><ul><li >文件夹:"&folder.name&"</li><li id='filename'>"&Right(folder.Path,Len(folder.Path)-Instr(folder.Path,"\upfile"))&"</li><li>"&folder.datelastmodified&"</li><li><a href='show.asp?action=openfile&folderPath="&folder.Path&"'>打开</a></li></ul></div>")
Next
response.Write "<br/><hr/>"
For Each file in allFiles
response.Write("<div class='filelist'><ul><li >文件:"&file.name&"</li><li id='filename'>"&Right(file.Path,Len(file.Path)-Instr(file.Path,"\upfile"))&"</li><li>"&file.datelastmodified&"</li><li><a href='show.asp?action=delfile&filePath="&file.Path&"'>删除<a></li></ul></div>")
Next
response.Write "<br/><hr/>"
response.Write "<a href='javascript:' οnclick='self.location=document.referrer;'>返回上一页</a>"
end function
'子程序名:信息提示窗口
'功能:信息提示,并作返回或者转向
'参数:
'str 提示字符串
'stype 处理类型:Back 返回 GoUrl 转向 Close 关闭
'url 转向方向
'************************
Sub MsgBox(str,stype,url)
response.write "<script language=javascript>"
response.write "alert('"&str&"');"
select case stype
case "Back"
response.write "self.location=document.referrer;"
case "GoUrl"
response.write "window.location='"&url&"'"
case "Close"
response.write "window.close()"
end select
response.write "</script>"
End Sub
%>
</Body>
</HTML>