Solved

open custom file on double click (file association)

Posted on 2010-11-09
6
461 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
  • 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

777 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