asp生成静态页面HTML的问题
把动态页面转换为静态页面,采用下面的代码:
<%
Call CreateHtml("http://192.168.1.7/index.asp","index.htm","/")
Function CreateHtml(Url, Filename, Path)
Set MyFileObject = Server.CreateObject("Scripting.FileSystemObject")
Path1 = Server.Mappath(Path) & "\" & FileName
Set MyTextFile = MyFileObject.CreateTextFile(Path1)
MyTextFile.WriteLine(GetHTTPPage(Trim(Url)))
MytextFile.Close
Response.Write "生成" & FileName&"成功<br>"
Set MyFileObject = Nothing
End function
Function GetHTTPPage(Url)
On Error Resume Next
Dim Http
Set Http = Server.createobject("Microsoft.XMLHTTP")
Http.open "GET", url, False
Http.send()
If Http.Readystate <> 4 Then Exit Function
GetHTTPPage = BytesToBSTR(Http.ResponseBody,"GB2312")
Set Http = Nothing
If Err.number <> 0 Then
Response.Write "<p align='center'><font color='red'><b>服务器获取文件内容出错</b></font></p>"
Err.Clear
End If
End Function
Function BytesToBstr(Body, Cset)
Dim ObjStream
Set ObjStream = Server.CreateObject("AdoDB.Stream")
ObjStream.Type = 1
ObjStream.Mode =3
ObjStream.Open
ObjStream.Write Body
ObjStream.Position = 0
ObjStream.Type = 2
ObjStream.Charset = Cset
BytesToBstr = ObjStream.ReadText
ObjStream.Close
Set ObjStream = Nothing
End Function
%>
放在web服务器中,通过设计让它每10分钟执行一次,产生index.htm文件,短时间内一切正常,过了几天后,程序就提示红色代码处没有权限,然后打开服务器,发现index.htm文件是0字节,想把它删除,提示该文件正被另一个人或程序使用,拒绝被删除,只有重新启动服务器后,才能删除它,再运行上述代码,则一切正常。为什么会出现index.htm被死锁的局面呢?