Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 14th, 2003, 07:26 AM
Authorized User
 
Join Date: Aug 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default Regarding " reading text files"

 Hi friends

 I have a text file "temp.txt" and I would like to use asp to read the first 3 lines and display using response.write.
the following prg reads the whole file

<%
Set fs=Server.CreateObject("Scripting.FileSystemObject ")
Set f=fs.OpenTextFile(Server.MapPath("testread.txt"), 1)

do while f.AtEndOfStream = false
Response.Write(f.ReadLine)
Response.Write("<br>")
loop

f.Close
Set f=Nothing
Set fs=Nothing
%>

But I need to read the first 3 line only ,
please help
Praveen

 
Old October 14th, 2003, 07:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try a simple loop like this:
Code:
Dim n
For n = 1 To 3
  If Not f.AtEndOfStream Then
    Response.Write(f.ReadLine)
    Response.Write("<br>")
  End If
Next





Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading text files senthilreddy ASP.NET 2.0 Basics 1 May 22nd, 2007 08:32 AM
Reading DBF Files SerranoG Access VBA 5 May 11th, 2005 07:33 PM
Reading excel and text files using VB6... CJ35 VB How-To 5 October 8th, 2004 03:56 AM
Reading from Binary Files jschmi J2EE 0 October 5th, 2004 01:09 AM
reading files nightsurfer JSP Basics 0 August 10th, 2003 04:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.