File Associations in ClickOnce Applications
One of the really cool features of ClickOnce applications is the ability to set file associations.
Note: File associations can only be set for Full Trust ClickOnce applications
The MSDN article walks you through creating a file association using XML in the application manifest, but most developers will find it easier to use the Project Properties screen:
Unfortunately, this is where the MSDN documentation leaves off, which tells you nothing about how your application knows the location of the file it is supposed to open. With a ClickOnce application, the file location is not passed in as a command line argument, it is actually in
One other interesting point is that the file location in ActivationData is in a uri form such as file://c:/temp/Test%20File.testApp. In order to use this as a path to IO functions like File.Exists, you’ll need to create a Uri from it, get the absolute path of the Uri, and Unescape the string (to convert %20 to a space):