In my application users create text based files and then they are saved into my own special filetype. When I create my clickonce project I am going to set it up so that my application opens these files when they are clicked open outside of the application.
My question is, how exactly do I write the logic so my program knows that it is opening through a file, so I can load the file into my application? I am geussing there is some kind of code I need to put in the form load to choose how the app is going to load, whether it opens a file or it loads as it normally would If I just opened it’s assembly. I am just not sure how I do that. I am using vb.net.
Would this work? How can I test this before I create my clickone program and set the filetype associations?
If (Environment.GetCommandLineArgs.Length > 1) Then
Dim s As String = Environment.GetCommandLineArgs(1)
' Open file s
End If
You have the right idea, take a look at this Code Project article(File-Association-in-VB-NET), it discusses exactly what you are asking.
From Link:
My.Application.CommandlineArgs. It returns aReadOnlyCollection(Of String).You can use
My.Application.CommandlineArgs(0)to retrieve the file path.