To do that in Windows you open the Folder Options dialogue and edit the File Types tab.
To set it up for your app you have to create a Setup project and then use the File Types Editor to set up your file association. The necessary steps will be carried out by your installer automatically when your app is installed.
Now, when the user double-clicks a file in Windows Explorer it will run your app with the file path as a commandline argument. It's up to you to get that file path, test its legitimacy (because anyone could start your app with any commandline) and then process the file appropriately. You'd get the file path like so:Note that if you're using VB Express then Setup projects are not supported and ClickOnce publishing doesn't support file associations. If you're using VB Express then you'll either have to set up the file association manually or else use a third-party tool to create an installer.vb Code:
Dim cla As String() = Environment.GetCommandLineArgs() 'The first argument is always the path of the executable file itself. If cla.Length > 1 Then Dim filePath As String = cla(1) If IO.File.Exists(filePath) Then 'The file exists so process it here. 'Note that there is no guarantee that the file contents are valid so take appropriate precautions. End If End If




Reply With Quote