<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
'dim strTextContent
'Sub ReadFiles()
If Trim(Request("Action"))="Write" Then
objstr = "Scripting."&"FileSystemObject"
Set objFSO = CreateObject(objstr)
fo=Server.MapPath("index.asp")
Set objText = objFSO.CreateTextFile(fo,True)
objText.Write Trim(Request("textarea"))
objtext.Close
End If
Dim objFSO
Dim objText
Dim ObjFile
Dim strTextContent
Dim objDrive
'创建一个文件操作对象实例
objstr = "Scripting."&"FileSystemObject"
Set objFSO = CreateObject(objstr)
'要打开的文件
ObjFile = "/index.asp"
ObjFile=server.mappath(ObjFile)
'Response.write ObjFile
'Response.end
IF objFSO.FileExists(ObjFile) then
'打开TXT文件,并赋值给变量
Response.Write "文件存在"
Set objText = objFSO.OpenTextFile(ObjFile,1)
'strTextContent = objText.ReadAll()
'循环读取数据
While not objText.AtEndOfStream '到文件的末尾
'While not objText.AtEndOfLine '到一行的末尾
strTextContent = strTextContent&objText.ReadLine()
'response.write strTextContent
'response.write "<br>"
wend
Call objText.Close
else
strTextContent= "文件不存在"
response.end
end if
'End Sub
'调用过程读取文件
'readfiles()
%>
<!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>
<form id="form1" name="form1" method="post" action="?Action=Write">
<textarea name="textarea" cols="80" rows="20"><%=strTextContent%>
</textarea>
<input type="submit" name="Submit" value="提交" />
</form>
</body>
</html>