I recently learned how to use VB.NET to set your program as the default for a chosen extension. You would write code to set a registry value. The problem is, when you open the file – after setting your program as default – it just opens your program (like a shortcut would). Is there a way that you could make it actually open the file? So say I have a text file. I set the default program for .txt files to my application. How would I make it load the text file, when I click to open the file, like you can if notepad is set to the default? If this doesn’t make sense, just let me know.
Share
The path to the file is passed to your program as a command line parameter. Your program will need to read the command line parameters and react accordingly.
Here is some example code demonstrating how to read the command line parameters:
To help with debugging this you can specify command-line arguments in the Visual Studio IDE: