I am just trying to learn to write to Binary files. When we create text files we normally give the extension .txt. The same way, what should be the file extension for Binary files created using C#.
Which are the contexts that demands us to write to a binary file. What is the benefit in writing/creating a binary file rather than a text file when processing data?
BIN and . DAT are the most popular extensions for "raw" binary file formats.
A DAT file is a generic data file created by a specific application. It may contain data in binary or text format. DAT files are typically accessed only by the application that created them.
Until the end of the text file is reached perform the following steps: Read a line from the input text file, into 3 variables using fscanf(). The structure variable is set to values for elements(to write the structure variable into the output file. Write that structure variable to the output binary file using fwrite().
bin file is a self-extracting binary file for Linux and Unix-like operating systems. Bin files often used for distributing executable files for program installations. The . bin extension is most commonly associated with compressed binary files.
Absolutely anything you want, or even nothing at all.
Just make sure you're consistent, and it helps not to use an extension already in wide use such as .doc or .pdf
Microsoft once advised using long extensions of the form .company-program-format
[1] since you can have extensions longer than 3 characters now, but this never took off to gain wide acceptance in the industry.
1: Footnote: I cannot find a source for this claim but I remember reading it on MSDN around the time Windows Vista came out. You see it in Windows OS files like dvr-ms
. These former guidelines are alluded to in this page, but the it's link is now broken and points to a totally different page: https://msdn.microsoft.com/en-gb/library/windows/desktop/cc144156(v=vs.85).aspx#short_and_long
From my experience, .BIN and .DAT are the most popular extensions for "raw" binary file formats.
But it's just a general convention, you are not limited to follow it in your own projects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With