R
ralpugan
Hi,
I don't know whether anyone faced it, using .NET 2.0, i'm loading a
text file into a string array then adding it to a listbox or use a
loop to see the context anywhere to see the content:
Dim content() As String = System.IO.File.ReadAllLines("c:
\nonblank.txt")
Listbox1.Items.AddRange(content)
My text file's last TWO lines are blank, but after loading it to a
listbox or when i loop through it, i ONLY see ONE blank line in the
whole output which is weird.
My text file's content:
' I will comment out to specify which lines are really blank
line1
line2
line3
line4
line6
line7
line8
line9
line10
' Here is blank-line11
' Here is blank-line12
Now, to test, create a text file that consists in 12 lines above
(leave last 2 lines blank), and remove comments and leave them blank
(not empty char, completely blank), load it into a string array using
IO.File.ReadAllLines and load them into a listbox with AddRange method
(preferably).
In the output, i always see there's one blank line after line 10 (that
is line 11) and line 12 doesn't appear. That means why ReadAllLines
doesn't read all the lines with all the blank lines till the end.
I'm uploading a screenshot to make it more clear:
http://img26.imageshack.us/img26/4906/readalllines.jpg
Output on listbox:
http://img26.imageshack.us/img26/6100/listbox.jpg
Does it indicate a problem about ReadAllLines? I hope someone makes a
clear explanation about it.
Thanks!
ralpugan
I don't know whether anyone faced it, using .NET 2.0, i'm loading a
text file into a string array then adding it to a listbox or use a
loop to see the context anywhere to see the content:
Dim content() As String = System.IO.File.ReadAllLines("c:
\nonblank.txt")
Listbox1.Items.AddRange(content)
My text file's last TWO lines are blank, but after loading it to a
listbox or when i loop through it, i ONLY see ONE blank line in the
whole output which is weird.
My text file's content:
' I will comment out to specify which lines are really blank
line1
line2
line3
line4
line6
line7
line8
line9
line10
' Here is blank-line11
' Here is blank-line12
Now, to test, create a text file that consists in 12 lines above
(leave last 2 lines blank), and remove comments and leave them blank
(not empty char, completely blank), load it into a string array using
IO.File.ReadAllLines and load them into a listbox with AddRange method
(preferably).
In the output, i always see there's one blank line after line 10 (that
is line 11) and line 12 doesn't appear. That means why ReadAllLines
doesn't read all the lines with all the blank lines till the end.
I'm uploading a screenshot to make it more clear:
http://img26.imageshack.us/img26/4906/readalllines.jpg
Output on listbox:
http://img26.imageshack.us/img26/6100/listbox.jpg
Does it indicate a problem about ReadAllLines? I hope someone makes a
clear explanation about it.
Thanks!
ralpugan