用fso文件對象刪除附件

mzcih 2003-08-23 02:21:06
<%
dim delid
delid = Request("myid")
sql="select wj from share where id="&delid 'wj字段記錄"文件名"
rs.open SQL,conn,3,3
do until rs.eof
wj=rs("wj") '斷判此字段是否為空
loop
if wj<>"" then
set delfile=server.CreateObject("scripting.filesystemobject")
delfile.deletefile"c:\wj" 刪除C:\下"相應"的文件
end if
set rs=nothing
set conn=nothing
%>

以上語句執行時出錯,是那裡錯了呢?請指教。謝謝!
...全文
75 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
mzcih 2003-08-25
  • 打赏
  • 举报
回复
TO:jjgn(jjgn)

谢谢你!

问题终于解决了,谢谢各位!

最终代码:

If wj<>"" then
Set fso=Server.CreateObject("Scripting.FileSystemObject")
DelFile=Server.MapPath("upload/"&wj&"")
If fso.FileExists(DelFile) Then
fso.deletefile DelFile
End If
End if
lxd1979 2003-08-24
  • 打赏
  • 举报
回复
同意各位的观点
jjgn 2003-08-24
  • 打赏
  • 举报
回复
If fso.FileExists(Server.Mappath("&wj&"))=true Then
fso.DeleteFile Server.MapPath("&wj&")
End If
我用了虚拟路径,不是像你所说的物理路径,你再转换就行了,我一直在用的
webcsdn 2003-08-23
  • 打赏
  • 举报
回复
不客气,大家一起学习
mzcih 2003-08-23
  • 打赏
  • 举报
回复
TO: webcsdn(极限)

谢谢!大家都来看看呀!
webcsdn 2003-08-23
  • 打赏
  • 举报
回复
gz
mzcih 2003-08-23
  • 打赏
  • 举报
回复
TO: huejim(Muck Feggie)

也行不通,大家帮帮忙好吗?
mzcih 2003-08-23
  • 打赏
  • 举报
回复
TO: huejim(Muck Feggie) 謝謝,我再試試.
huejim 2003-08-23
  • 打赏
  • 举报
回复
Set fso=CreateObject("Scripting.FileSystemObject")
WilPFile=Server.MapPath("/xxx/xxx.asp")
If fso.FileExists(WilPFile) Then
fso.deletefile WilPFile
End If

mzcih 2003-08-23
  • 打赏
  • 举报
回复
TO: jjgn(jjgn)

謝謝,但行不通!
mzcih 2003-08-23
  • 打赏
  • 举报
回复
TO:linday(林)

當然有權限啦!
mzcih 2003-08-23
  • 打赏
  • 举报
回复
謝謝!我試試.
linday 2003-08-23
  • 打赏
  • 举报
回复
存在与否/权限有无
jjgn 2003-08-23
  • 打赏
  • 举报
回复
<%
dim delid
delid = Request("myid")
sql="select wj from share where id="&delid 'wj字段記錄"文件名"
rs.open SQL,conn,1,1
if not rs.eof then
wj=rs("wj") '斷判此字段是否為空
if wj<>"" then
Set fso=Server.CreateObject("Scripting.FileSystemObject")
If fso.FileExists(Server.Mappath("&wj&"))=true Then
fso.DeleteFile Server.MapPath("&wj&")
End If
Set fso=Nothing
end if
end if
set rs=nothing
set conn=nothing
%>
Brookes 2003-08-23
  • 打赏
  • 举报
回复
delfile.deletefile"c:\wj"
删除之前确认有此文件FileExists判断
确认iuser_XXX有足够的权限

28,391

社区成员

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

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