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