当前位置: 移动技术网 > IT编程>开发语言>Asp > FSO 读出TXT文件

FSO 读出TXT文件

2017年12月12日  | 移动技术网IT编程  | 我要评论
<!--#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) %>


如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网