Append string with no newline

Hello im making a string out of three line all has new line

then add up more

my issure when i write to a file will always add new line
image
CRLE

I don’t want to use replaces want to keep the lines in order.
for example

lineOne newline
lineTwo newline
linethree newline

when i append to a file it will be

lineOne newline
lineTwo newline
linethree newline
NewLine

BR/Hazem

Hi @Hazem_Saleh

Try using .Trim before appending it to the text file. .Trim() method is used to remove leading and trailing whitespace (spaces, tabs, etc.) from a string.

Hope it helps!!

Thanks i forgot to mention i have white space need to keep !
Trim or trimend * \r\n will remove all spaces i need

Hi @Hazem_Saleh

What is your exact requirement?

Regards

I have this string
which can be duplicated thats why in the end i have Environment.NewLine()
Header +Environment.NewLine()+Body+ Environment.NewLine()+footer+ Environment.NewLine();

but when i append to a file its auto add newline “CRLF” trying to skip it with keeping the white spaces in the Footer line

Hi @Hazem_Saleh

Try this:

string.Concat(header, Environment.NewLine, body, Environment.NewLine, footer);

Regards

Concat has ignored the Enviroment.newLine now alll on one line!

/Hazem

Hi,
i dont append to file directly first i collect the string =+ Header +Environment.NewLine()+Body+ Environment.NewLine()+footer+ Environment.NewLine();

some times i have 9 lines same as above

when i use Concat its ignore the newline !!!