File
-
Hi everybody How can find out number of characters in a file?
Best Regards, Reza Shojaee
-
Hi everybody How can find out number of characters in a file?
Best Regards, Reza Shojaee
File.ReadAllBytes.Count, or something like that You may be able to get it from the FileInfo class also.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
File.ReadAllBytes.Count, or something like that You may be able to get it from the FileInfo class also.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
Christian Graus wrote:
File.ReadAllBytes.Count, or something like that
That'll work for ASCII and UTF-32, but not for UTF-8 and some other encodings with variable character length.
File.ReadAllText(path).Length
should work better. regardsDepends, if it's a text file or a binary file, and if he wants file size, or number of characters.
Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.
-
Hi everybody How can find out number of characters in a file?
Best Regards, Reza Shojaee
using System.IO;
FileInfo info = new FileInfo("filename.txt");
long charCount = info.Length;"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001