I'm using the writeAlltext method to save a text file with the contents saved in string variable namely textFile1.

File.WriteAllText(saveFileDialog1.FileName, textFile1);

However for each blank line i'm getting two boxes in the output text file. I need to keep the formatting as it is while saving a file. the blank lines are being replaced by the boxes.

Any ideas?

What do you mean by boxes? Any nonprintable character is most often printed as a "box" character. I suspect linefeed and carriage return characters here.(ASCII 10 and 13, ASCII 65 is the 'A' character)

It's the line feed i guess i've to deal with. But how? How can I have a check on the ascii and even if i get's the line feed ascii how will I be able to represent it with a line feed in text file instead of nonprintable box char.

As I said, i'm using the File.WriteAllText method.

thx

What do you mean by boxes? Any nonprintable character is most often printed as a "box" character. I suspect linefeed and carriage return characters here.(ASCII 10 and 13, ASCII 65 is the 'A' character)

Change to multiline text boxes?

Please find the attached file to see the output text. There should be a line gap or a start of a new paragraph which is not the case. Rather the box char is being saved instead of a line feed while saving the contents to .txt file using File.WriteAllText method.

Change to multiline text boxes?

I see no boxes or empty lines when I open Output.txt with NotePad.

Very common mistake for who works with files, that they don't replace \n with \r\n
your text in textbox.Text = "lmlmalma\n lmlmla" that's wrong to do that File.WriteAllText(saveFileDialog1.FileName, textFile1); rather File.WriteAllText(saveFileDialog1.FileName, textFile1.Replace("\n", "\r\n"));

Hm...strange

Can you see the difference b/w the two. The Personal Loan one is what I want and the output one is what i'm actually getting.

I hope you can notice the line spaces in the first one which i'm unable to produce in the output one.

I see no boxes or empty lines when I open Output.txt with NotePad.

Did you check my reply?

Got it. Thanks man, it solved the problem :)
thx

Very common mistake for who works with files, that they don't replace \n with \r\n
your text in textbox.Text = "lmlmalma\n lmlmla" that's wrong to do that File.WriteAllText(saveFileDialog1.FileName, textFile1); rather File.WriteAllText(saveFileDialog1.FileName, textFile1.Replace("\n", "\r\n"));

You're more than welcome, please don't forget to mark the thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.