Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 21st, 2007, 10:00 PM
Registered User
Join Date: May 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default read text file

HI Guyz,

               I'm a newbie in asp.net. What i would like to do is read a text file , take certain values and post them back in a page.

For example let say a a.txt file which contains :

name :


age :




name :


age :


designation :




i would like to take only the values next to line with name and age only :::: name (jenna,senthil) age:(20,25)

and post them back in a new page.

i could read the whole file and post everything.:

<%@ Import Namespace="System.IO" %>

<SCRIPT Runat="Server">

Sub Read_File_Fields (Src As Object, Args As EventArgs)

  Dim FileReader As StreamReader
        FileReader = File.OpenText("C:\Documents and Settings\user1\My Documents\Works Senthil\Celcom Billing\17.Celcom - Billing\02.Celcom-Dell\TH.dat")

  Dim LineIn As String
  Dim FieldArray() As String
  Dim Field As String

  LineIn = FileReader.ReadLine()
  If Not LineIn = Nothing Then
            FieldArray = Split(LineIn, ",")

    '-- Display table header
    FileContents.Text &= "<table border=""1"">"
    FileContents.Text &= "<tr style=""background-color:#F0F0F0"">"
    For Each Field in FieldArray
      FileContents.Text &= "<th>" & Field & "</th>"
    FileContents.Text &= "</tr>"

    '-- Display table rows
    LineIn = FileReader.ReadLine()
    While LineIn <> Nothing
      FieldArray = Split(LineIn, ",")

      '-- Display a table row
      FileContents.Text &= "<tr>"
       For Each Field in FieldArray
       FileContents.Text &= "<td>" & Field & "</td>"
      FileContents.Text &= "</tr>"

      LineIn = FileReader.ReadLine()
    End While

    FileContents.Text &= "</table>"
  End If

End Sub


<form id="Form1" Runat="Server">

<b>Read Celcom Bills Fields: </b>
<asp:Button Text="Read File" OnClick="Read_File_Fields" Runat="Server"/>

<p><asp:Label id="FileContents" EnableViewState="False" Runat="Server"/></p>


How could i pick only a few values such as the name and age. The values for name is on the next line. Help me out if there is a way. I'm using vwd with sql express.the place i'm stuck is how to search for the line says (age/name) and find for the next line. i could noy picturize how the codes could look like. thank you for ya help.

  #2 (permalink)  
Old December 19th, 2010, 10:56 PM
Authorized User
Points: 198, Level: 3
Points: 198, Level: 3 Points: 198, Level: 3 Points: 198, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2008
Location: singapore, singapore, Singapore.
Posts: 54
Thanks: 0
Thanked 4 Times in 4 Posts

It is a very old question, but if anyone struggles in the same way you may use the following

You can use the filesystem for Vb.Net Read Text File easily pass the string into a variable.

split the string using name or read until you find 'name' in the string. then for each stop read the other attributes(age, etc...) then use another string to form the display string as you did in your code.
Pon Saravanan

Last edited by pons_saravanan; December 19th, 2010 at 10:59 PM..

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Read and Edit the text file stuartlittle C# 3 February 26th, 2008 05:35 AM
Read Text file and convert to Binary file VB.net sjlsysprg1 Pro VB.NET 2002/2003 4 June 29th, 2007 06:53 AM
How to read a line from a text file ? nobitavn94 C# 3 November 25th, 2006 11:04 PM

All times are GMT -4. The time now is 12:02 AM.

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