简体   繁体   English

文本文件:逐行读取文件

[英]text file: Reading file line by line

but after reading file getting output of 2nd Line is not getting with same space.why但是在读取文件后,第二行的 output 没有得到相同的空间。为什么

THE industrial area layout                              date 11/12/2020                            
Head office                                             page no                             
   
  

below is my code下面是我的代码

 lines = File.ReadAllLines(path,Encoding.UTF8));

text file:文本文件:

  THE industrial area layout                              date 11/12/2020                            
  Head office                                             page no    

After Reading:看完之后:

  THE industrial area layout                              date 11/12/2020                            
  Head office                               page no                            

How would i be able to do this?我怎么能做到这一点? Thanks in advance.提前致谢。

Make sure you are analyzing the content with the same font, more specifically make sure you have monospace fonts otherwise you might get confused related to the spaces.确保您使用相同的字体分析内容,更具体地说,请确保您有等宽 fonts 否则您可能会对与空格相关的内容感到困惑。

I would suggest Courier New.我会建议快递新。

What you see in the debugger text view doesn't use a monospace font by default so it's unreliable when checking the number of spaces between lines especially when there's other content besides spaces.您在调试器文本视图中看到的默认情况下不使用等宽字体,因此在检查行之间的空格数时它是不可靠的,尤其是当除了空格之外还有其他内容时。

Another way to check the number of spaces is to replace them with some other character so that you can count them visibly.检查空格数量的另一种方法是将它们替换为其他字符,以便您可以明显地计算它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM