Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

open custom file on double click (file association)

Posted on 2010-11-09
6
Medium Priority
?
473 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 2000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

730 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