When I’m generating a text file programatically, should I insert the ASCII EOF marker (decimal value 26) at the end of the file?
Do the .NET Programming Languages do this automatically?
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.
There’s no reason for the
^ZEOFmarker anymore (and there hasn’t been for a long time) – it’s a hold over from CP/M which did not support exact lengths for file sizes in the directory – file sizes were in terms of the number of 128 byte blocks, so to end a file on a non-128 byte boundary you had to use an EOF character.Since early versions of MS-DOS were heavily influenced by CP/M (and Microsoft wanted CP/M programs to port easily), the convention stuck.
Your program should open text files with the appropriate attributes so the OS and/or language runtime will signal an EOF when it sees a
^Zin case you come across a file that uses the convention. But there’s no need to write one anymore.One possible exception is if you have a binary file, but want to put some text at the start of it, then a
^Z, then your data. If someone dumps it to the console it’ll say something intelligent instead of spewing garbage. There’s not a whole lot of reason to do this, but I’ve seen that done rarely.From Wikipedia (http://en.wikipedia.org/wiki/CP/M):