删除最后一个换行符(C#)使用StreamWriter生成文件时 [英] Remove Last Line Break (C#) When generate File using StreamWriter

查看:397
本文介绍了删除最后一个换行符(C#)使用StreamWriter生成文件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

掌握所有人的问候,



根据我的标题标签,

我在使用文件生成的函数streamwriter时删除换行符时遇到问题...

我一直在谷歌搜索,每个样本都在每个论坛,我已经尝试实现..但仍然它仍然无法消除行生成文件末尾的换行符....



我将非常感谢所有人的意见和建议,

我的情况还有其他办法。



谢谢



最好的反映所有,



chester

解决方案

而不是修剪文件中的最后一个换行符(注意平台上的行尾字符依赖于平台,请参阅 http://en.wikipedia.org / wiki / End_of_line [ ^ ]),避免写它。为此,请确保使用 System.IO.StreamWriter.Write 具有相同的参数。



请参阅: http://msdn.microsoft.com/en-us/library/system.io.streamwriter.aspx [ ^ ]。



-SA

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

解决方案

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


这篇关于删除最后一个换行符(C#)使用StreamWriter生成文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆