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?

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

thank you

You are welcome.

Please close this thread out if your problem is solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.