pulling info from file folders to program

Discussion in 'Programming General' started by alexandr, Apr 29, 2008.

pulling info from file folders to program
  1. Unread #1 - Apr 29, 2008 at 6:12 AM
  2. alexandr
    Referrals:
    0

    alexandr Guest

    pulling info from file folders to program

    how do you pull information from file folders to the program, ex. the items that are in the list box on program startup are items from a file folder. if you dont understand just tell me.. ill try to explain better.
     
  3. Unread #2 - May 7, 2008 at 7:55 PM
  4. DeathIncognito
    Referrals:
    0

    DeathIncognito Guest

    pulling info from file folders to program

    Well, if you haven't figured this out yet, this should help a bit.

    What's needed:

    1 Form named Form1

    1 Listbox named lbxFiles

    1 Folder in the C drive labeled "Test Folder" (pretty much any folder will work)

    Code:
    Imports System.IO
    
    Public Class Form1
        Private dir As New IO.DirectoryInfo("C:\Test Folder")     'Change the folder path as needed
        Private fileArray As IO.FileInfo() = dir.GetFiles("*.*")  'Change *.* to filter file extensions/names, ex. *.txt, *.bmp  or asdf.*
        Private file As IO.FileInfo
    
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            For Each Me.file In Me.fileArray
                lbxFiles.Items.Add(Me.file.FullName)
            Next
        End Sub
    
        Private Sub lbxFiles_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbxFiles.DoubleClick
            If (lbxFiles.SelectedIndex >= 0) Then
                Dim proc As New Process
                Dim procInfo As New ProcessStartInfo
    
                procInfo.FileName = lbxFiles.SelectedItem.ToString
                procInfo.UseShellExecute = True
    
                proc.StartInfo = procInfo
                proc.Start()
            End If
        End Sub
    End Class
    
    Well, that is it. I added the double-click event handler so that the program is somewhat useful. If you could elaborate on what you want to do with the listbox items or the desired file types, that would help. Also, if you don't want to change the source to edit the folder path, then just add a folder browser dialog and set the [dialogName].selectedpath to a variable and pass it to IO.DirectoryInfo([pathVariable]).

    Hope this helped.
     
< how would i make it so.. | A Little Java Help >

Users viewing this thread
1 guest


 
 
Adblock breaks this site