How do you set up a file association with a click-once application?

≯℡__Kan透↙ 提交于 2019-12-20 10:55:58

问题


I have a click-once application.

I have an associated file that I store the application's data in.

When a user clicks on one of these files I want it to open the click-once app and load the file.

I can set up the file association in the publish, the icon and name is correctly set. Clicking on the file opens the application, but the application doesn't seem to be passed the path to the file - the command arguments are empty.

How do I get it so that the path to the file is passed to the application?


回答1:


When using Click Once, arguments are not passed in on the command line, they are passed in through the Click Once deployment system:

AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData

For example, in your Program.cs file:

foreach (string commandLineFile in AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData)
{
    MessageBox.Show( string.Format("Command Line File: {0}", commandLineFile) );
}

Hope this helps.



来源:https://stackoverflow.com/questions/521038/how-do-you-set-up-a-file-association-with-a-click-once-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!