0

I have a C# program which works with files created by itself. The file can be opened by running the program and then accessing it via the GUI.

How can I open the file without having to run the program explicitly and just by double clicking on the concerned file?

JohnFx
  • 34,542
  • 18
  • 104
  • 162
jcvegan
  • 3,111
  • 9
  • 43
  • 66
  • 9
    I believe he is asking how to register a file extension to his program so that his program opens when you double click a file in explorer. – JohnFx Feb 20 '12 at 16:52
  • Yes, And how to develop it on c# – jcvegan Feb 20 '12 at 16:52
  • 2
    You need to associate the file type with your application. Usually applications take the filename as a parameter. I've seen this shown as `%1` in Explorer dialogs. For example, `winword.exe %1` opens with MS Word – Courtney Christensen Feb 20 '12 at 16:54
  • What is the file's extension? If it is not already used by a popular program you have a good shot at this. If the extension is already in use you can add open with your program to the context menu. http://stackoverflow.com/questions/6702627/c-sharp-how-to-add-my-program-to-context-menu – jac Feb 20 '12 at 17:03

3 Answers3

1

You have to add registry entries in your installer to associate your program's file extension with your application.

Here is an article in MSDN that will tell you what you need to know about file associations: How File Associations Work

JohnFx
  • 34,542
  • 18
  • 104
  • 162
1

Typically you'd do this with your install, if you're not using an installer or ClickOnce, then you can do it from code, but you have to muck about in the registry: http://mel-green.com/2009/04/c-set-file-type-association/

Ragoczy
  • 2,907
  • 1
  • 19
  • 17
0

You're asking how to associate a file type with your application. You can do this by adding entries to the registry using C#.

Community
  • 1
  • 1
Mike Atlas
  • 8,193
  • 4
  • 46
  • 62