I have referenced this thread and the website it points to: http://stackoverflow.com/questions/9161/opening-a-file-in-my-application-from-file-explorer
As of now, I can't get My.Application.CommandLineArgs to work properly. Any time I select an file to open in my program I get a windows error forcing the program to close. I only want to get the file path from My.Application.CommandLineArgs and pass it to a function that will then parse the file (a text file of various extensions, even if it is not associated with my program) and display the contents in a RichTextBox. My function to open the file is complete and works, but if I try to use My.Application.CommandLineArgs on a file the program crashes immediately. here is the code I'm trying as a test:
Private Sub ParseCommandLineArgs()
If My.Application.CommandLineArgs.Count > 0 Then
MessageBox.Show(My.Application.CommandLineArgs(1))
Else
MessageBox.Show("No args")
End If
End Sub
If I just open the application, I get the message box telling me no args were supplied, if I try to use "open with" my application for any file my application crashes. I have this function called during form_load.