计数文件中的C#字符数 [英] Counting number of characters in a file C#

查看:131
本文介绍了计数文件中的C#字符数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何使用C#计算一个文件的字符数?


解决方案

  FileInfo的F =新的FileInfo(文件名); 
长文件长度= f.Length;



文件长度将字节数在文件中,这将对应于字符数(假设单字节编码)。


How do you count the number of characters in a file using C#?

解决方案

FileInfo f = new FileInfo(fileName);
long fileLength = f.Length;

The fileLength will be the number of bytes in the file, which would correspond to the number of characters (assuming single-byte encoding).

这篇关于计数文件中的C#字符数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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