Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I was checking out the files in a old game called Warcraft 3 and saw that they had files with their own extension for example file name.w3x

so, how do you make your own file extension and run it?

share|improve this question
add comment

5 Answers

up vote 9 down vote accepted

In short: you make your own file extension by apply what ever letters you want to the end of the file name. you run it by telling your OS what program should be called when you double click on it.


Full explanation:

A file extension is actually just the letters after the file, there is nothing magical about the extension. a lot of files I have made when I'm on my Linux machines i have forgotten to even put the file extension on.

That being said, In windows the file extension is how windows determines what the file is. if you change the file extension of an .mp3 for example to a .png windows will think it is a picture when it tries to open it. What windows does is it looks at the extension and sends the file to an appropriate program related to that file. so .mp3 get sent to iTunes, .png get sent to paint brush, .html get sent to firefox/chrome, and .docx get sent to word.

In terms of the creation of these files, they fall into two categories. there are plain text files (.html, .txt, .java, .py, .cpp, .config, .xml) and then there are binary data files (.exe, .mp3, .png) (well, and then there are mixes of binary and plain text like the .docx, but they can be treated like binary files). When you are dealing with plain text files (it is plain text if notepad can open it) it is very easy to do. Depending on your programing language you basically just open a file and read/write strings to the file. With binary files it gets a little more complicated, but the principle remains the same, you are reading/writing bytes from a file.

To make it so you can execute that type of file when you double click on it is probably he hardest step depending on your programing language. if it is c or c++, you simply point windows to your .exe and windows sends the file you wish to open as the second argument in args to your program's main method. In java or python it is still do able, but you'll have to work out some sort of workaround to get windows to open the Runtime enviorment or interpreter and send the file argument to the program.

share|improve this answer
add comment

Assuming since you're talking about Warcraft III you're on Windows. Also assuming you're not wanting to do this programatically (otherwise you would have asked on stackoverflow).

Save a file with your custom extension. Open the file in Windows Explorer and it will ask you how to open it. Choose "pick from list", select the program you want, and check "Always use the selected program to open this kind of file". Voila, you can now "run" files with your custom extension.

share|improve this answer
    
thanks all of you for the tip. –  mendez Dec 7 '11 at 15:37
add comment

The .w3x extension is a map extension. Warcraft 3 doesn't run this extension, it's just map data.

They have their own algorithm / markup language to create these files and how to read them.

share|improve this answer
add comment

Well, uhm, just save the file under some name and that extension. "Running" it is a litte more difficult, and depends partially on the OS as well.

share|improve this answer
add comment

You will need to choose a programming language, then write a program which looks for files with an extension you have chossen. Those files must also be written so the program looking for them can read, understand and execute the code within.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.