如何设置与一次单击应用程序的文件关联?
我有一个单击一次的应用程序。
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) );
}
希望这会有所帮助。