www.gusucode.com > ASP+ACCESS在线教育系统设计(源代码+论文) > ASP+ACCESS在线教育系统设计(源代码+论文)\王智_在线教育系统\chat\1.asp

    <%@ Language=VBScript %>
<HTML>
<HEAD>
<meta http-equiv="Refresh" content="25;url='1.asp#tail'">
</HEAD>
<BODY bgColor=#fdf5e6>
<center>
<font color=red  size=10 face=隶书>实时答疑</font><br>
</center>
<%

dim fileobject
dim textfile
dim filepath

filepath = server.MapPath("1.txt")

set fileobject = server.CreateObject("Scripting.FileSystemObject")
'下面是写入过程
if fileobject.FileExists(filepath) then
	'如果记录文件已经存在
	set textfile = fileobject.OpenTextFile(filepath,8,true,0)
	if request("sentence")="" then
		
	else
		textfile.writeline "<font color=blue>" & request("user") & "</font>" & "("&now()&")"&":"& replace(replace(request("sentence"),"<","&lt;"),">","&gt;")
	end if
	textfile.close
else
	'如果记录文件不存在
	set textfile = fileobject.CreateTextFile(filepath)
	textfile.WriteLine(now())
	textfile.close
end if
'下面是读出过程
set textfile = fileobject.OpenTextFile(filepath,1,false,0)

do while not textfile.AtEndOfStream
	Response.Write textfile.readline&"<br>"
loop

textfile.close

%>

<a name="tail"></a>
</BODY>
</HTML>