Why do some .Net exceptions end with a newline

I have a ListView that shows an error to the user. Part of it also includes an exception message. The error is also written to the log file.

Now I noticed that some exception messages end with a new line. for example, File.Move may return a message (English .Net 3.5 SP1) "Unable to create file if this file already exists. \ R \ n" .

A new line makes listview and logfiles look weird. Adding .Trim () fixes the problem, but there is a reason for the new line.

+3
source share
2 answers

. mscorlib.dll, - , Windows API FormatMessage(). - 183, ERROR_ALREADY_EXISTS. Mscorlib.dll :

IO.IO_AlreadyExists_Name=Cannot create "{0}" because a file or directory with the same name already exists.

. , (System.IO.WinIOError), , {0}. -, , . Windows, FormatMessage(), , , .

, , connect.microsoft.com. , , . - , Message, , IOException. , , .

+2

, , .Net. , , , - , . , ( ), , , .

+2

Source: https://habr.com/ru/post/1724940/


All Articles