Search code examples
vb.netvisual-studiofile-association

How do I get the path to the associated file used to launch a program?


I have a program with an associated file type. However, when I double-click a file to launch the program, I can't figure out where that path was passed to the program.

Initially I thought the file path would be in Environment.CommandLine, but the command line only contained the program path.

I specified the file association using the Publish Options in visual studio like so: extension: .ext, Description: Some File, ProgId: ProjectName, Icon: SomeIcon.ico.


Solution

  • You are right, it should indeed be passed as a command line argument and be available through Environment.CommandLine.

    My guess is that something is wrong with the file association itself. Here is a dated but still useful TechNet article on how these things work. In particular, the "%1" in the screenshot below is essential.

    Screenshot of action editing dialog

    I'm not sure about the DDE thing, so if you're not using it, turn it off.