programmingsite : code , tutorials and scripts
Navigation

home


ASP
ASP.net
C
C++
C#
PHP
Java
JavaScript
Powershell
VB.net

Visual Basic


Resources
code
tutorials
training

Ads
Products

 

 

Reading a file





Reading a file

In this example we open a file which is in this case called sampletext.txt . This file contains several lines which we wish to display , so we loop the lines of text one at a time and display them until there are none left to display.


<%
Const ForReading = 1
' our variables
Dim objFSO , objTextStream , strText , strFileName
'Path to our text file
strFileName = Server.MapPath("sampletext.txt")
'create an instance of the FileSystemObject
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'open our text file
Set objTextStream = objFSO.OpenTextFile(strFileName , ForReading , False)
If not objTextStream.AtEndOfStream Then
Do While not objTextStream.AtEndOfStream
'read in our text one line at a time and display it
strText = objTextStream.ReadLine
Response.Write strText & "<br>"
Loop
End If
objTextStream.Close
'good practice to setobject variables to nothing
Set objFSO = Nothing
Set objTextStream = Nothing
%>





Products
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals
Asp Studio 2005
Xtra PHP
Online PHP Script Encoder
Comparison

Links
Make money selling software
Uk shopping
UK price comparison
US price comparison
free articles
free stuff
Gambling resources
Software directory
XBox cheats and more
Sexy free wallpapers
Hosting resources
Nintendo Wii info
Beginners PHP
Health and fitness
Domain names
Dating site
Nintendo DS resources
Dropshippers
Maxi directory
Perfume and fragrances
PC shopping, tips and info
Magazine superstore

Ads