自定义文件类型:获取调用文件的名称

huangapple go评论68阅读模式
英文:

Own filetype: get name of calling file

问题

我创建了一个使用ClickOnce Deployment部署的Visual Studio vb.net Windows Forms应用程序,然后将自定义文件类型与此应用程序关联:

项目 -> 属性 -> 发布 -> 选项 -> 文件关联

当我发布应用程序并手动创建一个文件,例如Testfile.abc,它会获得定义的图标,并且通过双击它来打开我的应用程序。

问题:如何在我的应用程序中确定哪个文件(例如c:\temp\Testfile.abc)启动了我的应用程序?
我了解到命令行参数以及第一个参数是文件名,但在这里它是我的应用程序的文件名(*.exe)。

英文:

I created a Visual Studio vb.net Windows Forms App and I a deploying it using ClickOnce Deployment.
Then I associated an own filetype with this app:

Project -> Properties -> Publish -> Options -> File Associations 

自定义文件类型:获取调用文件的名称

When I publish the App and I create manualle a file e.g. Testfile.abc it gets the defined icon and by double clicking it opens my Application.

Question: How can I determine in my application, which file (e.g. c:\temp\Testfile.abc) started my App?
I read about command line parameters and that the first parameter is that filename, but here it is the filename of my App (*.exe).

答案1

得分: 1

如Hans Passant在https://stackoverflow.com/questions/1759850/clickonce-file-association/1766013#1766013中正确发布的解决方案所述:

如果不是 (AppDomain.CurrentDomain.SetupInformation.ActivationArguments Is Nothing) Then
    ListBox1.DataSource = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData
End If
英文:

As posted correctly by Hans Passant the solution in https://stackoverflow.com/questions/1759850/clickonce-file-association/1766013#1766013 works:

If Not (AppDomain.CurrentDomain.SetupInformation.ActivationArguments Is Nothing) Then
    ListBox1.DataSource = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData
End If

huangapple
  • 本文由 发表于 2020年1月3日 19:15:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/59577620.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定