Results 1 to 4 of 4

Thread: Open program through file [REALLY SOLVED]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    297

    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??
    Last edited by HWijngaarD; Jan 20th, 2006 at 04:00 AM.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Open program through file

    VB Code:
    1. 'FIRST COMMAND LINE ARG IS THE FULL PATH TO THE RUNNING EXE
    2.         If Environment.GetCommandLineArgs.Length > 1 Then
    3.             'IF THERE IS MORE THAN 1 COMMAND LINE ARG, THEN
    4.             'IT WOULD BE THE FILE THAT WAS OPENED THAT LAUNCHED THE APP
    5.             'MAY WANT TO INCLUDE ERROR HANDLING IN HERE INCASE SOMEONE
    6.             'PUT THEIR OWN COMMAND LINE ARGS
    7.             Dim FileToProcess As String = Environment.GetCommandLineArgs(1)
    8.             MessageBox.Show(FileToProcess)
    9.         End If

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    297

    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?

  4. #4
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width