how in Delphi could I open binary file in non-text mode?
Like C function fopen(filename,"rb")
how in Delphi could I open binary file in non-text mode? Like C function
Share
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 are a few options.
1. Use a file stream
2. Use a reader
You would combine the above approach with a
TBinaryReaderto make the reading of the values simpler:The reader class has lots of functions to read other data types. And you can go in the opposite direction with a binary writer.
3. Old style Pascal I/O
You can declare a variable of type
Fileand useAssignFile,BlockRead, etc. to read from the file. I really don’t recommend this approach. Modern code and libraries almost invariably prefer the stream idiom and by doing the same yourself you’ll make your code easier to fit with other libraries.