Possible Duplicate:
Filetype association with application (C#)
I'm writing a C# Windows app to visualise and modify '.build' files (nant scripts). I would like the user to be able to right click on a .build file in windows explorer and select the 'Open With >' option to allow the file to be modified in my app.
What does my program need to support in-order to work with this mechanism? What might my program need to do to Windows to enable context menu support?
I was wondering if anyone could point me in the direction of a good article/tutorial on this subject.
The Open With command just passes the path of the file as the first argument to the application so all you need to do is
public static void Main(string[] args)
{
if(args[0] != null)
{
//args[0] contans a path to the file do whatever you need to do to display it
}
else
{
//Start normally
}
}
To automaticly put your program in the open with list you will need to add some reg keys in HKEY_CLASSES_ROOT\YOUR_EXT\
. Here is a SO answer saying how to do it
Or you could just add it by hand to the open with list the normal way.