When the user opens a file that way the file path gets passed to the selected application as a commandline argument. For instance, if you were to right-click on the file C:\Test.txt and select Open With -> Notepad, it would be equivalent to select Start -> Run and typing "notepad c:\test.txt" (without quotes).
In your application you would generally retrieve commandline arguments using the Environment.GetCommandLineArgs method. It returns an array where each element is an argument. The first is always the name/path of the application EXE itself. Any beyond that were passed to the app when it was run. You can test that array for length first to see if there are any commandline arguments. If there are you can get them and process them appropriately. In your case that would involve calling File.Exists to make sure that it's a valid file, then opening the file in whatever way is appropriate for its content.