|
>Free printable Sudoku Puzzles | Custom Word Search Puzzles | iptocountry.info | Free web storage |
| FileSystemObject: Reading a file
Read, ReadLine, ReadAll, Skip, SkipLine, Column, Line, AtEndOfLine, AtEndOfStream |
We will consider a file with the following content:
| learn.txt |
| 1234567890
abcdefghij ABCDEFGHIJ |
We will read this file in different ways in order to use various commands
available with filesystemobject.
| Read (number) Will read number of characters specified (after reading position in the file will change) | ||
| <%
Set fso = CreateObject("Scripting.FileSystemObject") Set a = fso.OpenTextFile(Server.MapPath("\") & "/learn.txt") mystring=a.Read(4)
Response.Write ("<hr>") mystring=a.Read(4)
Set a = Nothing
|
1234
5678 |
|
| ReadLine (will read content in one line of the text file) | ||
| <%
Set fso = CreateObject("Scripting.FileSystemObject") Set a = fso.OpenTextFile(Server.MapPath("\") & "/learn.txt") mystring=a.readLine
Set a = Nothing
|
1234567890
abcdefghij ABCDEFGHIJ |
|
| ReadAll (will read all the content in the text file) | ||
| <%
Set fso = CreateObject("Scripting.FileSystemObject") Set a = fso.OpenTextFile(Server.MapPath("\") & "/learn.txt") mystring=a.readAll
Response.Write ("<pre>" & mystring & "</pre>")
Set a = Nothing
|
1234567890abcdefghijABCDEFGHIJ
1234567890 abcdefghij ABCDEFGHIJ |
|
| Skip (number) Skip number of characters specified (after reading position in the file will change) | ||
| <%
Set fso = CreateObject("Scripting.FileSystemObject") Set a = fso.OpenTextFile(Server.MapPath("\") & "/learn.txt") a.Skip(5)
Set a = Nothing
|
67890 a
cdefghij Line break is two characters |
|
| SkipLine Skips line in the text file (after reading position in the file will change) | ||
| <%
Set fso = CreateObject("Scripting.FileSystemObject") Set a = fso.OpenTextFile(Server.MapPath("\") & "/learn.txt") a.SkipLine
Set a = Nothing
|
abcdefghij | |
| Column / Line will return position in the text file | ||
| <%
Set fso = CreateObject("Scripting.FileSystemObject") Set a = fso.OpenTextFile(Server.MapPath("\") & "/learn.txt") a.Skip(15)
Set a = Nothing
|
ColumnNumber: 4
LineNumber: 2 |
|
| AtEndOfLine Will let us know when the line ends | ||
| <%
Set fso = CreateObject("Scripting.FileSystemObject") Set a = fso.OpenTextFile(Server.MapPath("\") & "/learn.txt") While not a.AtEndOfLine
Set a = Nothing
|
1
2 3 4 5 6 7 8 9 0 |
|
| AtEndOfStream Will let us know when the file ends | ||
| <%
Set fso = CreateObject("Scripting.FileSystemObject") Set a = fso.OpenTextFile(Server.MapPath("\") & "/learn.txt") While not a.AtEndOfStream
Set a = Nothing
|
1234567890
abcdefghij ABCDEFGHIJ |
|
|
|
Create word search puzzles with your own words
|
2008@ AspTutorial.info. All rights reserved.