What event trigers when we open file with our exe/program?
How to do coding for that?

Recommended Answers

All 6 Replies

Process.Start("exeprocessname","filename")

eg. Process.Start("Notepad.exe","C:\text.txt")

Hi pooja,
What does exactly happen when we open file with?
And above code where to write that in load event? That looks like manually writing.
Actually i wanted to know how can I take arguments from system when user will open file with our program by right click>open with?

There is no event that I am aware of that triggers when you open a file from within your program. You don't need an event triggered because you are already executing code, starting with the method you called to open the file. As for "open with", you can set your program as the default in the Open With dialog. If you don't want to set it as the default then clear the "Always Open With" checkbox.

Hi Jim,
honestly i am not understanding, can u please suggest any link or upload any small program so it will clear the idea? Please

You can get the command line arguments in the collection My.Application.CommandLineArgs

Because you are passing the filename as an argument to your program, you would process it (open the file) in your form load event handler.

Perfect! Thanks Jim thats what answer I was looking for, thanks!

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.