处理文件以删除空间 [英] processsing files to remove spaces

查看:77
本文介绍了处理文件以删除空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读取原始文件中的一行作为字符串,找到该行的长度,然后将字符串分成几部分.........再次写入文本文件....输入文件很大,此解决方案的成本很高!.

为了从文件末尾删除空格,我有一个想法正在研究...如果不是空格,则逐个字符地读取字符;如果其空间读取下一个字符,则逐个写入新文件...仍在处理...高复杂度运算

[edit]删除了伪代码块,大量的句点一次减少为三个-OriginalGriff [/edit]

I am reading line of the original file as string, find the length of the line then divide string into parts ......... write to the text file again.... the input file is large, the cost of this solution is high!.

for removing spaces from the end of files, I have an idea I am working on... read character by character if its not space write to anew file if its space read the next character...still working on it...high complexity operation

[edit]Spurious code block removed, large number of full stops reduced to three at a time - OriginalGriff[/edit]

推荐答案

从空格的开头和结尾删除空格C#中的任何字符串都很容易:
Removing spaces from the beginning and end of any string in C# is easy:
myString = myString.Trim();



为什么在C#中使用strlen?每个字符串对象都有其自己的Length属性...

您的意思是将其发布为问题还是对某人对问题的回答的评论?我问,因为第一部分似乎没有多大意义!您实际上想实现什么目的?



Why are you using strlen in C#? Each string object has it''s own Length property...

Did you mean to post this as a question, or as a comment on someone''s answer to a question? I ask, because the first part doesn''t appear to make a lot of sense! What are you actually trying to achieve?


AFAIK C#中没有任何痕迹.确定要执行C#吗?正确更新标签.

如果是C#,请使用Streams而不是File类中的静态方法.发布相关代码,以便有人帮助.
AFAIK there is no strlen in C#. Are you sure you are doing C#? Update the tag correctly.

If it is C#, use Streams rather than the static methods in the File class. Post the relevant code so that someone can help.


这篇关于处理文件以删除空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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