dcsimg
Results 1 to 3 of 3

Thread: Display List of File Types and Load Associated Program

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2013
    Posts
    43

    Display List of File Types and Load Associated Program

    Hi Guys

    I have a previous thread which wasn't very clear. This is what i need:

    A list of File Types (.txt, .csv, etc etc) (Displayed As "Text File", "Comma Sepera....")
    Once the File Type is Selected, It needs to load the most suitable program to create that type of file (Text = Notepad, CSV = Excel??? Notepad???)

    Please help... i could just load the list by hand and tell each item what to run. but i assume there is a way to recognise the extension and run the best program?

    Note this is to create a file... so i would probably have a list of options and keep the extension as a string in a tag for each item. How do i get the computer to load the best program associated with that extension string?

  2. #2

    Thread Starter
    Member
    Join Date
    Mar 2013
    Posts
    43

    Re: Display List of File Types and Load Associated Program

    Quote Originally Posted by DJ_Warp View Post
    Hi Guys

    I have a previous thread which wasn't very clear. This is what i need:

    A list of File Types (.txt, .csv, etc etc) (Displayed As "Text File", "Comma Sepera....")
    Once the File Type is Selected, It needs to load the most suitable program to create that type of file (Text = Notepad, CSV = Excel??? Notepad???)

    Please help... i could just load the list by hand and tell each item what to run. but i assume there is a way to recognise the extension and run the best program?

    Note this is to create a file... so i would probably have a list of options and keep the extension as a string in a tag for each item. How do i get the computer to load the best program associated with that extension string?
    Sorted it with this:

    Code:
    
        Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            ListView1.View = View.List
            ListView1.Items.Add("Word Document")
            ListView1.Items(0).Tag = "WINWORD.EXE"
            ListView1.Items.Add("Text File")
            ListView1.Items(1).Tag = "NOTEPAD.exe"
        End Sub
    
        Private Sub Openprogram()
            Dim startInfo As New ProcessStartInfo()
            startInfo.FileName = ListView1.SelectedItems(0).Tag
            Process.Start(startInfo)
        End Sub
    
        Private Sub Selection(sender As Object, e As EventArgs) Handles ListView1.SelectedIndexChanged
            OpenProgram()
        End Sub

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    103,236

    Re: Display List of File Types and Load Associated Program

    If you wanted to do this "automatically" then you'd have to read the data from the Registry. Windows has a dialogue that lists all registered file extensions and their default applications and lets you edit them and the information it displays is stored in the Registry. You could read the extensions themselves from the Registry if you wanted or, if you had your own list of extensions, you could check the Registry to see if they are registered and, if so, get their default applications.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width