using readalltext in visual studio

Ask the few things google does not know

Moderator: Dictators in Training

using readalltext in visual studio

Postby Naethyn » Tue Apr 18, 2006 3:44 pm

I am trying to read a multiple line notepad document and display the text in a multiline text box.
Here is the code I am using:

Dim messageString As String = My.Computer.FileSystem.ReadAllText(c:\test123.txt).ToString
infoTextBox.Text = messageString

Unfortunatly if the notepad document has multiple lines it shows as a black square character at the end of each line. It then displays that black character in the text box instead of creating a new line. When I debug and step through the code and copy the black box from the messageString variable and then paste it into a text editor or even visual studio it creates a line!

Any help would be greatly appreciated.

Thanks,
Nathan
User avatar
Naethyn
NT Traveller
NT Traveller
 
Posts: 2085
Joined: Wed May 04, 2005 12:13 pm

Postby Naethyn » Tue Apr 18, 2006 3:50 pm

Also,
The textvisualizer in debug mode can read the variable with mutliple lines. It doesnt solve the issue of writing it to a text box but it means the carriage control and line feed arent lost in the readalltext.
User avatar
Naethyn
NT Traveller
NT Traveller
 
Posts: 2085
Joined: Wed May 04, 2005 12:13 pm

Postby Gidan » Tue Apr 18, 2006 4:05 pm

Translate every char into its ascii char value, then when it gets to the little black box, if its no the correct value for a carriage return, replace it. Probably wont work, but its worth a try.
For to win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
User avatar
Gidan
Admin Abuse Squad
Admin Abuse Squad
 
Posts: 2892
Joined: Tue Jan 04, 2005 11:01 am

Postby Naethyn » Wed Apr 19, 2006 8:29 am

I found out the problem.

The code above actually works. The reason I was having trouble is because I also tried to save the information to SQL server. After doing what you said, I noticed that the carriage returns where not being saved on SQL. Only the line feeds.

I found this code to add in the carriage returns after saving to a sql server. vbLf and vbCrLf are constants in vb.net

messageString = Replace(messageString, vbLf, vbCrLf)
Maeya wrote:And then your head just aches from having your hair pulled so tight for so long...
User avatar
Naethyn
NT Traveller
NT Traveller
 
Posts: 2085
Joined: Wed May 04, 2005 12:13 pm


Return to Tech Support

Who is online

Users browsing this forum: No registered users and 44 guests

cron