create a linebreak in a file in asp.net?
I'm creating a file in asp.net (C#) with the streamwriter and it has to be according to a certain format that the receiver knows and can handle, so I need to be sure that I create the linebreaks the "right" way. Is there anything I should be aware of in that sense or can a "\n" do it?
Status:
Open Jan 16, 2007 - 03:07 AM
C#, .net
2answers
Answers
Jan 17, 2007 - 04:50 AM
dustPuppy...
Depending on how you're creating the info that's going into the stream, there are a number of ways you can do it, including the one you've described in your question.
While it's certainly not the only option, I've grown fond of using a StringBuilder in a situation where I'm appending a bunch of stuff to write to a stream. To ensure linebreaks, I use the following code:
StringBuilder sb = new StringBuilder();
sb.Append("blah, blah, blah");
sb.Append(Environment.NewLine);
sb.Append("more blah, blah, blah");
That puts a correct "newline" into the string that gets written into the stream.
I hope this helps,
Ric
Feb 10, 2007 - 01:59 AM
thanks Ric, you here are the points...
Answer this question
Share Your Own Experience & Expertise
We look to ensure that every question is answered by the best people with relevant expertise and experience, the best answers include multiple perspectives. Do you have relevant expertise or experience to contribute your answer to any of these commonly asked questions?
Add New Comment