i added file extesions to associate with my program from Puplish/Option/File Association

But i dont know how to execute related codes when users open the file associated with my program?

how can it perform a specific code associate file type and determine which file type it is after program loaded?

4 Years
Discussion Span
Last Post by TnTinMN

You need to retrieve the command-line arguments, if any, and test the first argument. It should be the file that launched the application.

        Dim fi As IO.FileInfo ' used to test for file properties
        If My.Application.CommandLineArgs.Count > 0 Then
            fi = New IO.FileInfo(My.Application.CommandLineArgs(0))
            If fi.Exists Then
                Select Case fi.Extension.ToLower
                    Case ".fred"
                        ' do something with fred
                    Case ".wilma"
                        ' do something with wilma
                    Case Else
                        ' do something else
                End Select
            End If
        End If
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.