I´m coding in C# and using Windows Forms.
I have a textfile and want to count all rows that are in it.
Peter;25
John;31
Jane;22
Thats three lines and i want to count them for example.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The best way would be to use something like:
That will only work in .NET 4, but will read a single line at a time. If you’re happy enough to load the whole file into memory in one go, you can use:
Note that if the file is large (or it’s on a network drive etc), this could take a long time, in which case you’d want to do it off the UI thread.