Take the 2-minute tour ×

I don't know what it is called but I want to be able to double click on my saved file and then my program should open and load the file. What is this called and how do I do it?

I am using c# wpf and .net 4.0


How about the last 2 fields, what am I supposed to write there?

enter image description here

share|improve this question
You can associate custom file extension with your program in the Windows folder settings –  sll Nov 24 '11 at 12:17
add comment

2 Answers

up vote 4 down vote accepted

That is a file association, if you want this to happen on a client machine you need to register your application as the default application for a given extension. This question might be handy.

To actually handle the opening you need to process the arguments that are handed to your application, they will contain the file path. You can get the arguments either in the override of Application.OnStartup (e.Args) or Environment.GetCommandLineArgs.

share|improve this answer
What about the last 2 fields in the image I have added to the question? –  FireFly3000 Nov 24 '11 at 13:41
@FireFly3000: I presume Icon should point to some image which he file then will show when associated, ProgID might need to reference your application or give it an ID. I have never used that tool, can't you find anything in its documentation? –  H.B. Nov 24 '11 at 16:32
add comment

you need to register the file extension and associate it to your program, either during the setup using certain APIs or from code when program executes the first time.

check these ones:

How to associate a file extension to the current executable in C#

Associate File Extension with Application

personally I do not like the 100% registry approach, there should be some Windows APIs for that and we should let those APIs to work without worrying about the Registry from our side, in my opinion.

share|improve this answer
add comment

Your Answer


