Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a String to a textbox - I only get the first char

Status
Not open for further replies.

StevoSimpson

Programmer
Apr 23, 2006
6
GB
Hi,

I'm having trouble getting a textbox to show strings properly.

I'm reading in a file into a String*, searching for a specific string within this, and saving the found string.

ie.
Code:
FileStream* fstrm = new FileStream(String::Concat(this->drive,this->DATpath),FileMode::Open,FileAccess::Read,FileShare::Read);
StreamReader* reader = new StreamReader(fstrm,System::Text::Encoding::UTF8);

String* info = reader->ReadToEnd();
String* line1 = info->Substring(7,64);

This works fine, I get the results I'm expecting when I output line1 into a file. (the full track name)
However, when I try adding line1 to a textbox:
Code:
textBox1->Text = line1;
all I get is the first character.

Any ideas why this would be happening? It's beginning to drive me insane!!
 
Doesn't look like C++, but could the String be one of those formats where every other character is a null. You'd have to translate it to a string type the text box understands.

I'm pretty rusty on those macros USES_CONVERSION, W2T, T2W etc

Just a shot in he dark

Jeb \0
 
Thanks for that info. You were right in thinking that the original String* did have null characters every other character. I thought I had managed to get rid of them like this:

Code:
info = info->Replace("\\0", "");

Although I'm not entirely sure if it has worked properly. If I write it straight to a file it works. If I store it in a 'track' object, then output into a file from there, the spaces have reappeared again! I'm guessing that it hasn't worked correctly, but its very strange.

Do those macros work in .NET?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top