What Is the File Extension When Creating Binary Files

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?

4 Answers

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: (v=vs.85).aspx#short_and_long

7

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.

The three letter extension is an important convention for determining file type. While there are many different kinds of binary files represented by extensions such as ".png", ".mov", or ".mp3", for a generic, no-special-meaning binary file such as you are looking for the customary extension would be ".bin".

There is no extension however if you use .BIN then almost everyone will assume you mean binary and that the file should be viewed within a hex editor

If the binary file contains a proprietary format then give the extension more meaning, eg if it should be opened with something other than a hex editor name it as such.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest