Open program through file [REALLY SOLVED]
let's pretend I have a program who can read textfiles into a database.
How can I arrange my program so that if I doubleclick the textfile
my program starts and reads the file into the database.
I allready associated my textfiles to my program, so that the app runs,
but I really don't have a clue how the program knows that I have clicked my textfile.
Anyone??
Re: Open program through file
VB Code:
'FIRST COMMAND LINE ARG IS THE FULL PATH TO THE RUNNING EXE
If Environment.GetCommandLineArgs.Length > 1 Then
'IF THERE IS MORE THAN 1 COMMAND LINE ARG, THEN
'IT WOULD BE THE FILE THAT WAS OPENED THAT LAUNCHED THE APP
'MAY WANT TO INCLUDE ERROR HANDLING IN HERE INCASE SOMEONE
'PUT THEIR OWN COMMAND LINE ARGS
Dim FileToProcess As String = Environment.GetCommandLineArgs(1)
MessageBox.Show(FileToProcess)
End If
Re: Open program through file
And where do I put these lines?
Into the Public Sub New()?
Apparently I know nothing about this kind of opening a program
And how do I debug this?
1 Attachment(s)
Re: Open program through file
you can put it wherever you want.. probably somewhere in the very beginning of the code.
you can debug it by setting a test command line argument in the projects properties. Set the command line to the full path of the file, and this will simulate your app being opened because a user double clicked that file.