Solved

open custom file on double click (file association)

Posted on 2010-11-09
6
466 Views
Last Modified: 2012-06-27
Hi Experts!
I need a piece of code in order to open a text file with a custom extension, ie: .xyz (Already associated with my app via setup)
I need the file to be loaded in a text box on my main form when the user double clicks on any file with that extension.
Help will be very appreciated.
Thanks in advance.
0
Comment
Question by:jorgemgonzalez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34097789
When you double-click a file, its path is passed to its associated executable as a parameter. Think of it like opening up a command prompt and doing something like:

    C:\path\to\my\executable.exe C:\path\to\some\file.txt

As such, you can interrogate the command line arguments for your application and open the first argument as a text file, read it, then display the text however you like--in this case, put it in your textbox.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 34097809
0
 
LVL 13

Expert Comment

by:gamarrojgq
ID: 34097840
Hi,

Try this, if your file contains no readable data, you will be able to see it in the textbox (assuming you have a textbox named textbox1)

        Dim strFile As String

        strFile = Command()
        strFile = strFile.Replace("""", "")

        Dim srdFile As New StreamReader(strFile)
        textbox1.Text = srdFile.ReadToEnd
        srdFile.Close()
        srdFile.Dispose()
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Closing Comment

by:jorgemgonzalez
ID: 34098463
Quick and excellent solution, much appreciated.
0
 

Author Comment

by:jorgemgonzalez
ID: 34098470
I also want to thank gamarrojgq: for the fast reply.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 34098661
NP. Glad to help :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question