In C#, How can I copy a file with arbitrary encoding, reading line by line, without adding or deleting a newline
问题 I need to be able to take a text file with unknown encoding (e.g., UTF-8, UTF-16, ...) and copy it line by line, making specific changes as I go. In this example, I am changing the encoding, however there are other uses for this kind of processing. What I can't figure out is how to determine if the last line has a newline! Some programs care about the difference between a file with these records: Rec1<newline> Rec2<newline> And a file with these: Rec1<newline> Rec2 How can I tell the