C# saving textbox.text to txt file. txt file doesn't recognize end of line character?

You should do like this string log = @"C:\log. Txt"; using (FileStream fs = new FileStream(log, FileMode. Create)) { using (StreamWriter sw = new StreamWriter(fs)) { foreach(string line in Textbox1.

Lines) sw. Write(line+sw. NewLine); } }.

You should do like this. String log = @"C:\log. Txt"; using (FileStream fs = new FileStream(log, FileMode.

Create)) { using (StreamWriter sw = new StreamWriter(fs)) { foreach(string line in Textbox1. Lines) sw. Write(line+sw.

NewLine); } }.

This work-around way worked! Thanks for the help, S.P. – PeteMerry Jan 17 at 9:37.

My guess would be that the Textbox creates unicode characters (two bytes per character). In what format are you reading the data? ASCII unicode UTF?

If I remember correctly /n/r is an old trick to write a newline character to the string but in what format and what does it mean? Environment. Newline is much better and would work on windows mobile/unix builds too.

I usually create a class level variable called br with environment. Newline as its content, creates much shorter code.

Yeah, basically the textbox1. Text is only a string when I used the /r/n. But with S.

P suggestion I could write a new line in text file with each line in textbox.text. Anyway thanks for your time for answering. I'll try to use your suggestion in my next project.

Thanks again Barfieldmv. – PeteMerry Jan 17 at 9:42.

Your code is correct. Just add sw.Close(); after sw. Write(Textbox1.

Text).

The problem is in Textbox1. Text field in the form, "\r\n" works fine, but when I copy the Textbox1. Text to log.

Txt, the log. Txt doesn't have new line where it's supposed to be. Instead there's a strange charater like this "" where "\r\n" is.

I think problem lies in the sw. But I don't know how to fix it. Could anyone give me a hand?

Help is really appreciated. Thanks in advance.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions