问题
I'm building two programs, a text editor and a zipper, but in this two programs I want to associate a file type to they, but how can I do this? Thanks.
回答1:
You need to edit the registry: http://support.microsoft.com/kb/257592
You'll probably want to use regedit to see previous file associations, to make sure you don't mess up.
c# registry basics
回答2:
I know this is an old thread, but I don't think you should be messing around with the registry like that. Especially not since ClickOnce and other deployment wizards have implemented a built-in capability to make a file-association. You can find this in Solution Explorer -> Project Properties -> Publish tab -> Options button -> File-associations tab. Here you have the ability to register a file-type using a custom icon, description of the file, and a program identification.
If you want to take a step ahead, you can do this with Single-instance applications as well. I did this in a tutorial project on my website: DrawIt In the project I'm setting up a TCP-listener in the first instance and in the second, third, ... instance I connect a TCP-client and send the ActivationArguments to the first one.
The most important code blocks are in the file Program.cs and void Start_server in Hoofdscherm.cs.
来源:https://stackoverflow.com/questions/1734192/associate-a-file-to-a-application