Click here to Skip to main content
11,932,402 members (57,110 online)
Click here to Skip to main content
Add your own
alternative version


36 bookmarked

File Type Creator

, 14 Sep 2006
Rate this:
Please Sign up or sign in to vote.
Shows you how to create your own file types and use them with your program.
Sample image


Ever since I started programming I wanted to know how to create my own file types to go along with my programs. It's actualy quite simple because VS.NET has it's own built in file types editor that comes along with your deployment projects. In this article I will show you how to create your own file types using the built in editor, how to open them with your program, and use them to open your program.

I hope you will stay and read the end of the article for a good laugh or two Smile | :)

Using The Source Code

Along with the downloadable source code files is a Deployment folder that contains the deployment project you'll need to add to the program. For the file type program to work you'll need to install it on your computer because the file type needs to be registered with the Windows Registry before it will work correctly.

Program Controls

The main project controls in this application are the Open Button - btnOpen, Save Button - btnSave, and 3 text boxes; TextBox1, TextBox2, and txtMessage.

The CommandLine()

Every time you run a program with Windows the variable CommandLine() holds the file path of the program you just opened as a String.  However, if you were to double click on a file that opens a program, i.e. .bmp would open Windows Paint, then the CommandLine() would hold the file path Strings of the program and the file that was clicked seperated by a space.  It made for some interesting turnouts as you'll see at the end of the article.

Source Code

When your program first starts up you need to run a test to see if the program was started by the user opening one of the registered files (not the program itself).  You can do this by testing the CommandLine() for the String ".mnft" (or whatever file type you registered).  If the CommandLine() does in fact contain that String the program makes the necessary calculations and then skips right to the Function functionFileOpen()

(.mnft = My New File Type)




<FONT size=2><P></FONT>

Using The File Types Editor

Opening The File Types Editor

Open the project you would like to add a file type to in VS.NET. On the main menu in VS.NET click File, scroll to Add Project (with the arrow), and click on New Project. Create your deployment project by selecting it in the dialog box and name it whatever you want to. Now, in Solution Explorer (probably on the right side of your screen) click ONCE on your newly created deployment project. In the main menu click View, go down one menu item to Editor, now click on File Types (Editor-->File Types).  If the deployment project is not selected there will be no Editor menu option.

Creating Your Own File Types

Now that you know how to open the File Types Editor it's time to learn how to create your own file types.

In the File Types Editor right click on File Types on Target Machine and click Add File Type. Select the new file type and set it's Properties to...

Name - My New File Type

Command - Primary Output for...your program    Note: You'll need to set up the File System on Target Machine prior to this

Extensions - mnft     Note: No period!

Icon - Pick one!

There! That's all there is to it!  Have fun exploring all the possibilities, like special encryption files that only your program can Code/De-Code.


OK, time to examine the fun part of the Form_Load event procedure.

<FONT size=2><P></FONT><FONT color=#0000ff size=2>  While</FONT><FONT size=2> quoteCharStop < 2 </FONT><FONT color=#0000ff size=2>And</FONT><FONT size=2> placeInString > 0</P><P>     charInLine = cmdLine.Substring(placeInString, 1)</P></FONT><FONT size=2><P></FONT><FONT color=#0000ff size=2>  If</FONT><FONT size=2> charInLine = Chr(34) </FONT><FONT color=#0000ff size=2>Then</P></FONT><FONT size=2><P>     quoteCharStop = quoteCharStop + 1</P></FONT><FONT size=2><P></FONT><FONT color=#0000ff size=2>  Else</FONT><FONT size=2> : newLine = charInLine & newLine</P><P></FONT><FONT color=#0000ff size=2>     End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>If<FONT size=2></P><P>  placeInString = placeInString - 1</P><P></FONT><FONT color=#0000ff size=2>  End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>While</FONT></FONT>

When I first coded this I made three mistakes.

1.  Instead of using Chr(34) I used Chr(32)       Don't laugh, it's not funny Smile | :)

2.  I used the typical this = this + somethingElse. But notice how we are building the string backwards!  So I needed to use the command this = somethingElse + this instead.

3.  I left the quotation marks in the file path String from the CommandLine().

So, with those three mistakes combined, imagine my surprise when the text in TextBox2 read

"tfnm.olleh/potkseD/cisaBlausiV/sgnitteS dnA

Whoops!  It only looped until I had two Spaces, Copied it backwards, and included the quotation mark!  I almost rolled off my chair upon seeing that one!

The reason you cannot leave the quotation marks in is because the variable already saves the file path as a string, so if you keep the quotation marks in there it won't open the file because file paths just don't include quotation marks.  Smile | :)

The End

I hope this article helps everyone out some.  Thanks for reading and feel free to ask questions!


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
3+ years Visual Basic.NET programming experience. A little ASP.NET and HTML as well.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Muhammady15-Mar-12 4:22
memberMuhammady15-Mar-12 4:22 
GeneralGetCommandLineArgs Pin
Malte Klena14-Sep-06 23:34
memberMalte Klena14-Sep-06 23:34 
GeneralRe: GetCommandLineArgs [modified] Pin
Yep-ItsMe15-Sep-06 2:32
memberYep-ItsMe15-Sep-06 2:32 
GeneralIcons and other [modified] Pin
Yep-ItsMe15-Aug-06 12:36
memberYep-ItsMe15-Aug-06 12:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151126.1 | Last Updated 14 Sep 2006
Article Copyright 2006 by Yep-ItsMe
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid