Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
dear all,
master his greetings to all,

according to my title tag,
I am having problems to remove line breaks when using a file generated function streamwriter ...
I've been googling here and there, each sample is in every forum, I have tried implemented .. but still it still can not eliminate the line break at the end of the line generated files ....

I would appreciate any opinion and its input from all of you,
is there any other way for my case.

thank you

best reagrds all,

chester
Posted
Comments
[no name] 16-Sep-13 13:37pm    
"I have tried implemented", you have tried what? What does your code do when you run it? Do you get any errors?
OriginalGriff 16-Sep-13 14:02pm    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Try showing the code that generates the file - it might just help, and prevent us from guessing...
Use the "Improve question" widget to edit your question and provide better information.

1 solution

Instead of trimming the last line break from the file (note that the end-of-line character(s) depend(s) on the platform, please see http://en.wikipedia.org/wiki/End_of_line[^]), avoid writing it. For this purpose, make sure you that instead of very last System.IO.StreamWriter.WriteLine you can System.IO.StreamWriter.Write with the same parameters.

Please see: http://msdn.microsoft.com/en-us/library/system.io.streamwriter.aspx[^].

—SA
 
Share this answer
 
Comments
chester_it21 16-Sep-13 14:40pm    
Hi all,

trims for comming and your time...
I've completed it,
I find his answer here:
http://stackoverflow.com/questions/1981947/how-can-i-remove-rn-from-a-string-in-c-can-i-use-a-regex
and this is exactly what @Sergey Alexandrovich Kryukov explain ...
@TheRhantomUpvoter "trims for your time..."
@OriginalGriff "I apologize if it is less detailed explanation, I mean above is when the file generate a record of the results of database rows."
@Sergey Alexandrovich Kryukov "trims sergey,Well, it's a different explanation sanget between System.IO.StreamWriter.WriteLine with System.IO.StreamWriter.Write, I was wrong when at the end of the line is still using the System.IO.StreamWriter.WriteLine..."

trims all...
Sergey Alexandrovich Kryukov 16-Sep-13 14:44pm    
I still highly recommend you to avoid extra end-of-line instead of trimming, but it's up to you.
Good luck, call again.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900