Results 1 to 3 of 3

Thread: [RESOLVED] [2005] Using VS2005 To read text files and separate lines.

  1. #1

    Thread Starter
    Frenzied Member dinosaur_uk's Avatar
    Join Date
    Sep 2004
    Location
    Jurassic Park
    Posts
    1,098

    Resolved [RESOLVED] [2005] Using VS2005 To read text files and separate lines.

    Hi there,

    I have found out how to read the contents of a file in one go.

    Now i need to separate the whole string into line by line, how do i do that?
    I understand i can use string.split command, but what is the character entry for the line break?

    Cheers!

    VB Code:
    1. If IO.File.Exists(Me.txtFilePath.Text) = True Then
    2.             Dim fileText As String = My.Computer.FileSystem.ReadAllText(Me.txtFilePath.Text)
    3.             Me.rtbContents.Text = fileText
    4.         End If
    If you find my thread helpful, please remember to rate me

  2. #2
    Hyperactive Member
    Join Date
    Aug 2003
    Location
    Wigan, UK
    Posts
    291

    Re: [2005] Using VS2005 To read text files and separate lines.

    Use ReadAllLines straight to an array
    VB Code:
    1. Dim fileText() As String = IO.File.ReadAllLines(Me.txtFilePath.Text)
    2.  
    3. 'or arraylist
    4. Dim fileText As New ArrayList(IO.File.ReadAllLines(Me.txtFilePath.Text))
    Last edited by thingimijig; Oct 5th, 2006 at 01:51 PM.

  3. #3

    Thread Starter
    Frenzied Member dinosaur_uk's Avatar
    Join Date
    Sep 2004
    Location
    Jurassic Park
    Posts
    1,098

    Re: [2005] Using VS2005 To read text files and separate lines.

    VB Code:
    1. Dim fileText() As String = IO.File.ReadAllLines(Me.txtFilePath.Text)
    2.             Dim str() As String = filetext(n).split(",")
    If you find my thread helpful, please remember to rate me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width