I need to strip the last line from a text file. I know how to open and save text files in C#, but how would I strip the last line of the text file?
The text file will always be different sizes (some have 80 lines, some have 20).
Can someone please show me how to do this?
Thanks.
With a small number of lines, you could easily use something like this
However, as the files get larger, you may want to stream the data in and out with something like this
For small files, an easy way (although far from the most efficient) would be: