ASP文件删除程序出错无效使用 Null: 'replace'

来源:百度知道 编辑:UC知道 时间:2024/06/09 01:56:37
</body>
</html>
<%
'过程:删除文件
Sub DelFile(fileurl)
dim temp_fileurl,FilePath,fsoDel
servername=Cstr(Request.ServerVariables("SERVER_NAME"))
temp_fileurl=trim(fileurl)
temp_fileurl=replace(temp_fileurl,"http://"&servername,"")
if temp_fileurl<>"" then
if instr(temp_fileurl,"http://")>0 then '是否为网上文件
else
set fsoDel=CreateObject("Scripting.FileSystemObject")
FilePath=Server.MapPath(temp_fileurl)
if fsoDel.FileExists(FilePath)then '文件是否存在
fsoDel.Deletefile(FilePath) '删除文件
set fsoDel=nothing
end if
end if
end if
end sub
%>

删除程序出错无效使用 Null: 'replace'
这表示字段fileurl中有NULL值,你可以在输出时加个""空字符再进行替换就不会出错了。
修改如下:
temp_fileurl=replace(temp_fileurl,"http://"&servername,"")
改为:
temp_fileurl=replace(temp_fileurl&"","http://"&servername,"")

servername=Cstr(Request.ServerVariables("SERVER_NAME"))此句改为:
servername="http://"+Cstr(Request.ServerVariables("SERVER_NAME"))

replace(temp_fileurl,servername,"")变成这样就可以了