FSO Read TXT file

Source: Internet
Author: User
Tags readfile
FSO <!--#include file= "dbconn.asp"-->
<%
function ReadFile (filename)
On Error Resume Next
Err.Clear
' An error-correction method for ASP
Const ForReading = 2
Const Create = False
Dim FSO
DIM TS
DIM filepath
DIM thefile
Dim Content

'---------------operation address

Set fso=server.createobject ("Scripting.FileSystemObject")
Filepath=server. MapPath ("temp")./notebook folder for storage

If Err.number<>0 Then
Response. Write "Directory does not exist"
Response. End
End If

' Filename= ' test.txt '---------test.txt the file name you read out of the database
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)%>




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.