Results 1 to 4 of 4

Thread: [2005] ReadAllLines vs NULL

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    49

    [2005] ReadAllLines vs NULL

    Well, a Happy Friday to everyone,

    Should ReadAllLines be renamed to ReadAllLines_unlessThereIsANullValueInTheData???

    I am trying to read a delimited file in to an array but there happens to be null values in some fields and ReadAllLines stores lines of data up to that point and then carries on losing some data in the process.

    Is there a way around this?

    Thanks for your help

    Gogi

  2. #2

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    49

    Re: [2005] ReadAllLines vs NULL

    Oh,

    I am using this.

    Code:
    Dim Lines As String() = IO.File.ReadAllLines(txtMainFile.Text)

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2005] ReadAllLines vs NULL

    When you say "null values" do you actually mean null characters? Null characters indicate the end of a string so it's logical that ReadAllLines would stop reading at that point. You shouldn't have null characters in a text file for that very reason: a null character isn't text; it's the end of text. If you want different behaviour then it's up to you to implement it yourself. You'd have to read the binary data of the file yourself with a FileStream object.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2006
    Posts
    49

    Re: [2005] ReadAllLines vs NULL

    Thanks jmcilhinney,

    I'll try and do something different - perhaps delete the file and pretend it never was

    Gogi

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