Opening a text file by double clicking

Discussion in 'Visual Basic ( VB )' started by Annorax, Sep 26, 2007.

  1. Annorax

    Annorax New Member

    Joined:
    Nov 12, 2006
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    QA Engineer
    Location:
    MA, USA
    Hi everyone,

    I am writing a simple text editor. I would like the ability to be able to right click on a text file in my system and "Open With" using my program. Here is what I have so far:

    Code:
    If Environment.GetCommandLineArgs() Is Nothing Then
    	'Make new file normally
    Else
    	'Open each file in Environment.GetCommandLineArgs() string array
    End If
    
    However, this yields in an error:

    Exception System.NullReferenceException was thrown in debuggee:
    Object reference not set to an instance of an object.

    Is this the best approach at doing this? I don't want to associate it with my program, just open it. I also noticed that in the Windows "Open With" list, my icon is there but my program name is blank. Is there a way to set this?

    Thanks for any help.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,341
    Likes Received:
    379
    Trophy Points:
    83
    I don't see any code in the above code block where it should have an exception and where do you get that exception.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice