FSO删除指定的文件(有劳各位高手了)

freeheartsz 2010-01-31 02:17:09
请教一个紧急的问题:
通过下面这段代码,我列出这个文件夹中的所有文件
现在想实现的功能是:
1.在列出的文件名追加一个删除的小图标
2.单击这个删除的小图标后弹出确认删除的对话框,若选择是,则删除该文件
3.删除完成后,对该页面进行刷新
唉,问题太多,真不好意思麻烦各位
实在想不出来如何做了.有劳各位高手了
<%
dim fso,fod,fil,o_c,f_c,siz,i
o_c=0:f_c=0:siz=0
set fso=server.createobject("scripting.filesystemobject")
pathStr="./upload/upload/SRM-"& request.form("textfield") &"/"
if trim(pathStr)="" then
response.write "未指定path参数!"
response.end
end if
temp_path=server.mappath(pathStr) '要遍历的文件夹路径
if not fso.folderexists(temp_path) then
response.write temp_path&" 不存在!"
response.end
end if

call getcount(temp_path,1)


'函数名getcount
'作用:遍历文件夹内的所有文件和子文件
'参数:path--要遍历的文件夹,i--文件/文件夹级数
function getcount(path,i)
t_path=path
set fod=fso.getfolder(t_path)
o_c=o_c+fod.subfolders.count
f_c=f_c+fod.files.count
'遍历文件夹中的文件
if fod.files.count>0 then
for each fi in fod.files
for j=1 to i

response.write "<a href=/qis/asp/srm/upload/upload/srm-"& request.form("textfield") &"/"&fi.name&">"

next
response.write fi.name&"(<font color=red>"&formatnumber(fi.size/1024/1024,2)&"MB"&"</font>)<br />"&vbcrlf



siz=siz+fi.size
next
end if
'遍历文件夹中的子文件夹,并回归调用
if fod.subfolders.count>0 then
for each ff in fod.subfolders
for j=1 to i
response.write "- - "
next
response.write t_path&"\"&ff.name&"(<font color=red>"&i+1&"</font>)<br />"&vbcrlf
response.flush '输出
c_fod=t_path&"\"&ff.name
call getcount(c_fod,i+1)
next
end if
end function
%>
...全文
47 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
freeheartsz 2010-01-31
  • 打赏
  • 举报
回复
自己顶一下先

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧