If you write MessageBox::Show("Строка1\nСтрока2"); Then at the output we get a message with two lines.

If we write the function of reading String ^ from a file into a variable and output this variable to the MessageBox, then the output is 1 line, where "\ n" will not be processed. And for me this is a problem, because as the whole text of the entire program, I read their xml files. How to process "\ n"?

I read the variable from the file like this:

 String^ Localization::txt(String^ control){ String^ value = ""; XElement^ str str = XElement::Load(path); access_localization(); if (access) { try { value = str->Element(control)->Value; } catch (Exception^ e){ MessageBox::Show(control + "\n\n" + e->ToString()); } } return value; } 
  • What does your question have to do with C ++? - user227465
  • Because I write in C ++ / CLI - Smirnov
  • @Smirnov Show your code reading from the file and the contents of the file - Anton Shchyrov
  • C ++ / CLI is not C ++. - user227465
  • What are you attached to C ++? By and large, my question is not particularly tied to the CLI. I read from the file like this: String ^ Localization :: txt (String ^ control) {String ^ value = ""; XElement ^ str str = XElement :: Load (path); access_localization (); if (access) {try {value = str-> Element (control) -> Value; } catch (Exception ^ e) {MessageBox :: Show (control + "\ n \ n" + e-> ToString ()); }} return value; } - Smirnov

1 answer 1

You need to convert

 str = str.Replace("\\n", "\n"); 
  • Thank you, just this moment I did not understand. Now everything works otlichno - Smirnov