Tutorials to .com

Tutorials to .com » Asp » Fso » FSO read TXT file

FSO read TXT file

Print View , by: iSee ,Total views: 13 ,Word Count: 262 ,Date: Thu, 16 Apr 2009 Time: 4:45 AM

<!--# include file = "dbconn.asp" ->
<%
function ReadFile (filename)
on error resume next
err.clear
'ASP a wrong way to school
Const ForReading = 2
Const Create = false
Dim fso
DIM TS
DIM filepath
DIM thefile
Dim content

Address'--------------- operation

Set FSO = server.createobject ( "scripting.filesystemobject")
filepath = server.MapPath ( "temp"). / records stored in a folder

if err.number <> 0 then
response.Write "directory does not exist"
response.End
end if

'filename = "test.txt" --------- test. txt for you to read out from the database file name
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)%>



ASP File System Object Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.