Reading last symbol from text file using C# -


this question has answer here:

what efficient way read last symbol or line of large text file using c#?

if file not too large, read lines , pick last:

string lastline = file.readlines("pathtofile").lastordefault(); // if file empty 

so last character in way:

char lastchar = '\0'; if(lastline  != null) lastchar = lastline.lastordefault(); 

file.readlines not need read lines before can start processsing, it's cheap in terms of memory consumption.

here more complicated way j. skeet: how read text file reversely iterator in c#


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -