1

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 

enter image description here

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).

Eñaut
  • 116
  • 11
Stefan Meyer
  • 889
  • 1
  • 9
  • 19
  • If you're using `Environment.GetCommandLineArgs()`, read the second parameter (if the length of the resulting array is > 1, that is). The first is always the application executable path. – Jimi Jan 03 '20 at 11:27
  • https://stackoverflow.com/a/1766013/17034 – Hans Passant Jan 03 '20 at 11:34

1 Answers1

1

As posted correctly by Hans Passant the solution in ClickOnce File Association works:

If Not (AppDomain.CurrentDomain.SetupInformation.ActivationArguments Is Nothing) Then
    ListBox1.DataSource = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData
End If
Stefan Meyer
  • 889
  • 1
  • 9
  • 19