Im trying a read a "text" file that is a storage file for a proprietory software package.
I can open the file up in notepad and read it all fine, all the data is there and visible in a plain text format, and i can also import the file into excel or basically anything else..
My problem is that when i attempt to read the file into a VB 2005 richtextbox, or textbox it won't read the whole file. (doesn't matter if i use read, readtoend, or readline with peek etc)
Has anyone come across something similar to this is there a charactor in my text file that cause the reader to think its finished
Any thoughts would be appreciated.
Regards
Mc

Reading a "text" File
Rustum
I was just using a basic streamreader to read the file, based on an openfiledialog result
If OFD1.ShowDialog = Windows.Forms.DialogResult.OK Thenss1.Text = OFD1.FileName
' statusbar filename display Dim custfile As New FileStream(OFD1.FileName, FileMode.Open, FileAccess.Read) Dim custread As New StreamReader(custfile) Try While custread.Peek > -1RichTextBox1.Text &= custread.ReadLine & ControlChars.CrLf
End Whilecustread.Close()
Catch ex As ExceptionMsgBox(ex.Message)
End Try End IfCan you see anything obviously wrong with the above code It seems to read other files perfectly, which leads me to beleive its not so much the code thats a problem, but the format of the file im reading. Im just not sure how im going to adjust the code to suit. Its a bit hard to post an example of the data file also :(
I hacked the file and saved it as a txt file, removing the first "record" which is a just a number (max records in file) and a whole lot of spaces. Funnily enough, the streamreader code above, works fine on this file.
I also worked out that each record is 512 characters in length, not counting the seperators.
Should i be able to tell the streamreader to skip the first 512 characters and then start reading
jacksparo
You can however manipulate the text by line in the richtextbox.
Without seeing code it would be just a guess.
HTH
fxcoper
In VB 6, the Text setting for a TextBox control is limited to 2048 characters unless the MultiLine property is True, in which case the limit is about 32K.
Regards
Kurt
JBeyer
marben79
sskalskii
Dman1
That piece of code worked! (or at least it appears to!) But it loads the entire file into the richtextbox. Which is good and bad.
I cant find anyway of loading the file by line
I have to do is determine the lengths of fields and split it into different fields (which is the whole purpose of the excercise). Precisely, i need to read the file by line, in chunks (basically a split function i guess) and add a "," after each chunk
The aim is to create a program that will import the entire contents of a file, and then dump out selected results direct to a csv format or direct to excel or a similar program.
The original data file i am trying to read can by anything from 3k to 3mb, depending on the amount of data.
It looks like there is "^^" betweem each record. The rest of the file appears to be written based on the length of each field in the program that creates it....
Many Thanks
Mc
Lorenzo Colautti
code please