运行结果:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>写文本</title>
</head>
<body>
<%
dim filestr,strtmp
dim filename,filepath
filename="new.txt"
filestr=""
filestr=filestr & "文本的中内容" & "<br>" & vbcrlf
filestr=filestr & "文本的第二行" & "<br>" & vbcrlf
filestr=filestr & "文本结束" & "<br>" & vbcrlf
filepath=Server.MapPath(filename)
set fileConn=Server.CreateObject("Scripting.FileSystemObject")
set fileOpen=fileConn.OpenTextfile(filepath,2,true)
fileOpen.write(filestr)
fileOpen.close
set fileConn=nothing
set fileOpen=nothing
Response.Write("文件名:")
Response.Write(filename)
Response.Write("<br>文件物理路径:")
Response.Write(filepath)
Response.Write("<br>文件的内容:<br><br>")
Response.Write(filestr)
%>
</body>
</html>
|