FSO 读出TXT文件
程序员文章站
2022-05-03 13:23:50
<%
function readfile(filename)...
<!--#include file="dbconn.asp"-->
<%
function readfile(filename)
on error resume next
err.clear
'asp的一种校错方法
const forreading = 2
const create = false
dim fso
dim ts
dim filepath
dim thefile
dim content
'---------------操作地址
set fso=server.createobject("scripting.filesystemobject")
filepath=server.mappath("temp") ./记录本存放的文件夹
if err.number<>0 then
response.write "目录不存在"
response.end
end if
'filename="test.txt" ---------test.txt为你从数据库里读出的文件名
thefile=filepath&"/"&filename
set ts = fso.opentextfile(thefile,1)
do until ts.atendofstream
response.write (""&ts.readline&"")
response.write("<br>")
loop
set ts = nothing
set fso = nothing
end function
%>
<%
dim id
dim filename
id=6
set rs=server.createobject("adodb.recordset")
sql="select * from yuan where id="&id
rs.open sql,cn,1,1
filename=rs("fileload")
%>
<% readfile(filename) %>
<%
function readfile(filename)
on error resume next
err.clear
'asp的一种校错方法
const forreading = 2
const create = false
dim fso
dim ts
dim filepath
dim thefile
dim content
'---------------操作地址
set fso=server.createobject("scripting.filesystemobject")
filepath=server.mappath("temp") ./记录本存放的文件夹
if err.number<>0 then
response.write "目录不存在"
response.end
end if
'filename="test.txt" ---------test.txt为你从数据库里读出的文件名
thefile=filepath&"/"&filename
set ts = fso.opentextfile(thefile,1)
do until ts.atendofstream
response.write (""&ts.readline&"")
response.write("<br>")
loop
set ts = nothing
set fso = nothing
end function
%>
<%
dim id
dim filename
id=6
set rs=server.createobject("adodb.recordset")
sql="select * from yuan where id="&id
rs.open sql,cn,1,1
filename=rs("fileload")
%>
<% readfile(filename) %>
上一篇: 沱牌酒价格表一览,献给爱喝酒的你
下一篇: IE功能汇总