ASP learning the FSO component Operation example skill (5)

Source: Internet
Author: User
fso| Skills

In this program is the mid function, the function is to return a string from the first few characters in the beginning. The format is: Mid (string,start,length)

<script language=vbs>
Cn_string= "Cnbruce Love Cnrose"
Cn_start = 9
Cn_length = 4
Alert (Mid (Cn_string,cn_start,cn_length))
</script>

Learned the FSO to extract the file value, but also learned to input the information into the file, then the following application.

Do not know you have no such habit: see a file, the unconscious right to choose to open Notepad. Oh, almost no document is not possible. So now, you can default all files are text, but the suffix name is different, so that is, you can now extract the contents of any file information. OK, Just imagine:

1, extract the path of a file (using the file button to find positioning)
2, open the path file and read all rows
3, displaying the read information

First, Viewcode. Asp

  <%function showcode (filename)
  set fso = Server.CreateObject (" Scripting.FileSystemObject ")
  set CNRS = FSO. OpenTextFile (filename, 1)
  while not CNRS. AtEndOfStream
  rsline = CNRS. ReadLine
  rsline = server. HTMLEncode (rsline)
  response.write (Rsline & "<br>")
  wend
   End function%>
  <form action= "viewcode.asp" method= "POST" > Input filename
  <input Type= "file" name= "filename" >
  <input type= "Submit" value= "View source program" >
  </form >
  <%file=request.form ("filename")
  response.write (file & source program is as follows   if trim (file) <>" then
  call showcode (file)
  end if%>

The above program debugging, you can choose Html,asp page, you can open any application and so on.
The ShowCode function is defined to open, read, and display all the contents of the information in the file. Note the server is added. HTMLEncode (Rsline) for files that contain standard HTML code.

Displaying all the rows in a file is displayed by looping through a conditional loop.

While not CNRS. AtEndOfStream ... Wend







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.