Programming Language Geek

May 18, 2008

What are file extensions?

Filed under: Supporting topics

File Extensions or File Name Extensions are just the last N valid characters after the last dot (.) of a file name. These are popularly known to be required specifically in a Windows Operating System. Basing on this definition, you can actually rename a certain file and have a brand new file extension of whatever name you’d want it to have, except that you cannot use some characters such as ‘/’, ‘\’, ‘:’, ‘*’, ‘?’, ‘"’, ‘|’, and ‘ ‘ (spaces).

How are these file extensions useful?

Simple, it is to quickly tell the computer what registered application to handle it. Let’s take ".txt" for example. If you open a ".txt" file, by default, it will be handled by Notepad. Even so a file is not actually a simple text file, if it has a ".txt" file extension, it will be sent to Notepad by default. The reason why this has to be this way is because, Windows OS wanted to create an operating system that is very user-friendly. I tell you guys, if there were no file extensions, whenever a user opens a file, he would still have to manually specify whether what application to handle it. Now this can become a hassle in the part of the user.

How do file extensions work?

A file extension should be registered in the list of recognized file by Windows. Then, later, it would have to be associated to the application handling it by default. This is termed to be as "File Association". When you double-click to a file having a file name extension, Windows quickly finds an application that is associated to its file extension. In the case of ".txt", since Notepad is associated with it, then Notepad would have to be the application to handle it by default. Nowadays, there are lots of files which have internal trademarks to help the application associated with its file extension easily recognize it as a valid format. This is the very reason why there are some files having a ".mp3" file extension, when sometimes opened to an mp3 player, produces an error saying "Invalid format!". Some files have trademarks which are found at the end of the file. This is to secure that the file has been properly transferred from one directory to another and ensure that the file is not broken.

Try this one: First (if you’re running under Windows XP), open any directory. Go to "Tools|Folder Options". In the "View" tab, look for the option "Hide extensions for known file types", then uncheck it. This allows viewing of files in its complete name (which means, you can fully see the file name including its file extension). Look for a common file, suppose an mp3 file. Now a regular mp3 file should have a ".mp3" file extension. You should be able to see its complete file name with the ".mp3" at the end. Rename the file and make sure you change the ".mp3" into a common file extension such as ".txt". Open the file by double-clicking on it. The contents of the file is actually meant for mp3, but you will notice that, instead of an mp3 player to handle it, Notepad will be the one to open it.

Important: Sometimes, if a file is being opened forcely by an incorrect application, the application may cause the file to be damaged. In programming, there are a few ways to open a file: open it as plain text, by sequence, by random, by binary, and many more. The safest way to open a file without damaging it is by binary. Anyway, you never know how an application handles a file. So, to be safe, don’t change the name extension of a certain file.

2 Comments »

The URI to TrackBack this entry is: http://plgeek.blogsome.com/2008/05/18/what-are-file-extensions/trackback/

  1. http://is.gd/idf

    Comment by ragingmon — May 19, 2008 @ 1:28 am

  2. I see, about the article above… Actually, in my PC, i always set my folder settings to allow file extensions to be shown.. As for the case of viruses as discussed in the article, you will notice that though you see that it has a file extension “.txt”, but the icon of the file is not for notepad, it is a clue that it is not really a text file…

    By the way, I forgot to mention, usually, when a file is being associated to an application, the file inherits the Icon allowed by the program. Therefore, you would notice that the file’s icon looks like the icon of the application opening it by default. (though this might not be true all the time, since there are cases that though the file is already associated with the application, the icon hasn’t been completely configured)

    Comment by plgeek — May 19, 2008 @ 7:49 am

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>


Get free blog up and running in minutes with Blogsome
Theme designed by Jay of onefinejay.com