I want to associate a file extension with my开发者_开发技巧 ClickOnce application. There is a File Associations part in the Publish options but I can't manage to make it work.
Have you added the code inside the application to handle the file name passed in when the user double-clicks on it and do something with it? You need something like this in your startup.
string fileName = string.Empty;
string[] activationData =
AppDomain.CurretnDomain.SetupInformation.ActivationArguments.ActivationData;
if (activationData != null && activationData.Length > 0)
{
Uri uri = new Uri(activationdata[0]);
fileName = url.LocalPath.ToString();
}
Then you have to add code to do something with the file.
In order to use file associations, your project must conform to a few rules...
- Full Trust is required.
- Must be available "offline".
- Must target 3.5 Framework.
If you are already doing all these things, what, exactly, isn't working?
精彩评论