asp如何读取当前目录下的文本
来源:百度知道 编辑:UC知道 时间:2024/05/11 03:03:41
agent=request.servervariables("http_user_agent")
if instr(agent,"IE")>0 then
读取当前目录下的文本1.txt并显示出来
else
读取当前目录下的文本2.txt并显示出来
end if
%>
<%
agent=request.servervariables("http_user_agent")
if instr(agent,"IE")>0 then
set myfileobject=server.createobject("scripting.filesystemobject")
txtfile = "1.txt"
set mytextfile=myfileobject.opentextfile(txtfile)
s = mytextfile.readall()
response.write(s)
else
set myfileobject=server.createobject("scripting.filesystemobject")
txtfile = "2.txt"
set mytextfile=myfileobject.opentextfile(txtfile)
s = mytextfile.readall()
response.write(s)
end if
%>
看看这样行不行?
怎么和我遇见的问题一样啊!麻烦你找到答案了告诉我!
一言难尽啊
这 可是一 工程
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f, Msg,path,ReadTextFileTest
path=server.MapPath(".")&"\1.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(path, ForReading)
ReadTe