Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

right i have a filelist that i want the user to select one file by double clicking.

 

then it will pass it to a list box in to a que but before it passes that file to the que i need a name assoiated with that file

 

ie when double clicked it will ask for a name then pass it to the file list box with the file name and the name the user gave

 

ie

 

Mike ---------- file name

diane---------- file name

 

then i am going to pass that file one at a time to winamp for playing so i must keep the file path somehow..

 

 

anyone anyideas how this can be done

  • Administrators
Posted

It might be easier to wrap the name / path into another class.

i.e.

Public Class FileItem
   Private ReadOnly _DisplayName As String
   Private ReadOnly _FilePath As String

   Public Sub New(ByVal DisplayName As String, ByVal FilePath As String)
       _DisplayName = DisplayName
       _FilePath = FilePath
   End Sub

   Public Sub New(ByVal FilePath As String)
       _FilePath = FilePath
       _DisplayName = System.IO.Path.GetFileNameWithoutExtension(FilePath)
   End Sub

   Public Overrides Function ToString() As String
       Return _DisplayName
   End Function

   Public ReadOnly Property DisplayName() As String
       Get
           Return _DisplayName
       End Get
   End Property

   Public ReadOnly Property FilePath() As String
       Get
           Return _FilePath
       End Get
   End Property

and use this with the list box. If you create an array of these you could use the array as the datasource and it will automatically use the DisplayName for the listbox text.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

that sounds fine this is my file browser in my form

 

the controls i have are

combobox = DrivesList

listbox = FoldersList

listbox = FilesList

listbox = KaraokeQue ---- the place i need to send the file que to ----

 

this is the code for my file browser

 


   Dim currentDir As String
   Public Shared E_Path As TextBox
   Dim modern As Date
   Public Shared Main_Files As ListBox
   Dim ChosenFiles() As String
   Dim intSize As Integer = 0
   Dim MyProgress As New ProgressBar
   Dim MyProgressCopy As New ProgressBar
   Dim StrGenre As String
   Dim Genre As Integer
   Dim tooltip1 As New ToolTip


       '****** file browser load ******
       modern = Date.Now
       'task.SelectedIndex = 2
       'E_Path = TextBox1

       On Error Resume Next
       If DrivesList.Text = "" Then
           DrivesList.Items.Clear()
           ShowAllDrives()
           DrivesList.SelectedIndex = 0
           Me.Text = Directory.GetCurrentDirectory
       Else
           DrivesList.Items.Clear()
           ShowAllDrives()
           DrivesList.Items.Insert(0, DrivesList.Text)
           DrivesList.SelectedIndex = 0

           'Me.Text = Directory.GetCurrentDirectory
       End If

       'MyProgress = ProgressBar1
       'MyProgress.Value = 0

       'MyProgressCopy = ProgressBar2
       'MyProgressCopy.Value = 0

       'Artist_ComboBox.Items.Insert(0, "Artist <Do Not Change>")
       'Album_ComboBox.Items.Insert(0, "Album <Do Not Change>")
       'TrackName_ComboBox.Items.Insert(0, "Track Name <Do Not Change>")
       'Year_ComboBox.Items.Insert(0, "Year <Do Not Change>")

       'CreateMyToolTip()

       '******** End file browser ******

   End Sub
   '***************************************************************************************
   '*************** Enumeration SubRoutines *****************************************
   '***************************************************************************************

   'FOLDERS LIST
   Private Sub FoldersList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FoldersList.SelectedIndexChanged
       Dim DI As DirectoryInfo
       Select Case FoldersList.Text
           Case ""
               MsgBox("Select a Folder to Expand", MsgBoxStyle.Information, "Batch Renamer")
               Exit Sub
           Case ".."
               Try
                   DrivesList.Text = ""
                   Directory.SetCurrentDirectory("..")
                   DrivesList.Text = Directory.GetCurrentDirectory
               Catch
               End Try

           Case Else
               Try
                   DrivesList.Text = ""
                   Dim Path As String = DrivesList.Text
                   DrivesList.Text = Path & FoldersList.SelectedItem
                   Directory.SetCurrentDirectory(DrivesList.Text)
                   'frmKaraoke.E_Path.Text = DrivesList.Text
               Catch : End Try
       End Select
       Dim folders() As String
       Dim selectedFolder As String = FoldersList.Text
       Try
           folders = Directory.GetDirectories(Directory.GetCurrentDirectory)
           FoldersList.Items.Clear()
           FoldersList.Items.Add("..")
       Catch : End Try
       Dim fldr As String
       For Each fldr In folders
           Try
               DI = New DirectoryInfo(fldr)
               FoldersList.Items.Add(fldr)
               'TextBox1.Text = fldr
           Catch : End Try
       Next
       'Me.Text = Directory.GetCurrentDirectory & " - [Mike N Dis Karaokes Form 2006 ]"
       Dim NewThreadStart1 As New ThreadStart(AddressOf Me.ShowFilesInFolder)
       Dim Newthread As New Thread(NewThreadStart1)
       Newthread.Start()

   End Sub

   'SHOW FILES IN FOLDERS
   Sub ShowFilesInFolder()
       Dim file As String
       Dim i As Integer = 0
       Dim FI As FileInfo
       'Dim selectedFile As String = fileselect.Text
       FilesList.Items.Clear()

       For Each file In Directory.GetFiles(Directory.GetCurrentDirectory)
           i = i + 1
       Next

       MyProgress.Maximum = i

       For Each file In Directory.GetFiles(Directory.GetCurrentDirectory)
           Try
               FI = New FileInfo(file)
               If InStr(LCase(FI.Name), "mp3") > 0 = True Or InStr(LCase(FI.Name), "ace") > 0 = True Or InStr(LCase(FI.Name), "zip") > 0 = True Or InStr(LCase(FI.Name), "rar") > 0 = True Then
                   If Not FilesList.Items.Contains(FI.Name) = True Then
                       FilesList.Items.Add(FI.Name)
                   End If
               End If
           Catch : End Try
           If MyProgress.Value < MyProgress.Maximum Then
               MyProgress.Value = MyProgress.Value + 1
           End If
       Next

   End Sub

   'DRIVES LIST

   Private Sub DrivesList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DrivesList.SelectedIndexChanged
       FoldersList.Items.Insert(0, "..")
       ShowFoldersInDrive(DrivesList.Text)
       ShowFilesInFolder()
   End Sub

   'SHOW ALL DRIVES

   Sub ShowAllDrives()
       On Error Resume Next
       Dim drives() As String
       drives = Directory.GetLogicalDrives
       Dim aDrive As String

       For Each aDrive In drives
           DrivesList.Items.Add(aDrive)
       Next
   End Sub

   'SHOW FOLDERS IN DRIVE

   Sub ShowFoldersInDrive(ByVal drive As String)
       Dim folders() As String
       Try
           folders = Directory.GetDirectories(drive)
       Catch
       End Try
       Dim fldr As String
       FoldersList.Items.Clear()
       FoldersList.Items.Insert(0, "..")
       Dim DI As DirectoryInfo

       For Each fldr In folders
           Try
               DI = New DirectoryInfo(fldr)
               FoldersList.Items.Add(DI.FullName)
           Catch
           End Try
       Next
       Try
           Directory.SetCurrentDirectory(drive)
           DrivesList.Text = Directory.GetCurrentDirectory & FoldersList.SelectedItem
           'Me.Text = Directory.GetCurrentDirectory & " - [Mike N Dis Karaokes Form 2006 ]"
       Catch : MsgBox(Err.Description, MsgBoxStyle.Critical) : End Try
   End Sub

 

so how do i add that bit in now

 

sorry i am still learning all this :confused:

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...