Results 1 to 4 of 4

Thread: [RESOLVED] Confusing File read issue

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2009
    Posts
    40

    Resolved [RESOLVED] Confusing File read issue

    Hey, I'm trying to read a file line by line into an array but It skips the item at index: 3 I have it msgboxing just to make sure and it wont even touch it. any help is appreciated

    Code:
       Dim Btn As Button = DirectCast(sender, Button)
            Dim path As String = Application.StartupPath & "\Libraries\" & Btn.Text.Replace(" ", "_") & ".ipt"
    
            Dim i As Integer = 0
            Dim lines As String() = IO.File.ReadAllLines(path)
    
            Dim arraymorph(lines.Length) As String
    
            Dim ReadMorphs As New IO.StreamReader(path)
    
            While ReadMorphs.Peek() <> -1
                MsgBox(ReadMorphs.ReadLine.ToString())
                arraymorph(i) = ReadMorphs.ReadLine
                i += 1
            End While
    textfile contents =

    @ALWAYSREPLACE
    a:4
    t:7
    textissue
    e:3

    just wont touch texttissue

    Thanks again

    Sumn3rd

  2. #2

    Re: Confusing File read issue

    You're calling ReadLine() twice. It'll read two lines per loop.

    Code:
    While ReadMorphs.Peek() <> -1
                Dim Str As String = ReadMorphs.ReadLine()
                MsgBox(Str)
                arraymorph(i) = Str
                i += 1
            End While

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2009
    Posts
    40

    Re: Confusing File read issue

    Pssh I left that there from when I was debugging it and still used it to test it. Turns out the method I was using to debug it was rooting it. Haha ironic. Thankyou

  4. #4
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: [RESOLVED] Confusing File read issue

    I don't understand it. In the following line you have already read all text lines from your file:
    Code:
     Dim lines As String() = IO.File.ReadAllLines(path)
    Why do you read them again into the arraymorth line by line?

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