'FSO' 读出TXT文件(牛啊)

王朝asp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

<!--#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) %>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航