如何设置与一次单击应用程序的文件关联? [英] How do you set up a file association with a click-once application?

查看:75
本文介绍了如何设置与一次单击应用程序的文件关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个单击一次的应用程序。

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?

推荐答案

使用单击一次时,参数不会传递到命令行,它们通过单击一次部署系统传递:

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

例如,在您的Program.cs文件中:

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) );
}

希望这会有所帮助。

这篇关于如何设置与一次单击应用程序的文件关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆