I am a newbie when it comes to programming and what i have done so far with my application is through sample codes, tutorials and with the help of fellow programers.
I am trying to pass data and file paths from one listbox1 to listbox2, now i can pass data from listbox1 to listbox2 but i am having problems with the paths to the files listed in the listbox's. The paths to the files listed in the listboxs are not shown, only there filenames.
My program will search a selected drive or folder for .wav files and list any found in listbox1 without there paths, (only there file names), now i have an add button so that the user can select an item in listbox1 and add it to listbox2. Now what i need to be able to do is to save the .wav files add to listbox2 to a folder which is coded in the application.
Now what i have tried so far is to add another two listbox's called listbox3 and listbox4 which are both hidden from the user.
Listbox3 holds the paths to all the .wav files found for listbox1 and listbox4 will hold the paths to the .wav files added to listbox2.
Listbox3 adds the paths to listbox4 when items are added to listbox2 from listbox1.
Below is the code that i have been trying to use.
Public Sub FileTypeFinder(ByVal dir As String, ByVal fileExt As String) Try ' Display all files in a directory that match file type For Each fname As String In IO.Directory.GetFiles(dir) If fname.EndsWith(fileExt) Then ListBoxControl1.Items.Add(My.Computer.FileSystem.GetName(fname)) listBoxControl3.Items.Add(fname) End If Next ' A recursive call for all the subdirectories in this directory. For Each subdir As String In IO.Directory.GetDirectories(dir) FileTypeFinder(subdir, fileExt) Next Catch ioex As System.UnauthorizedAccessException Catch ex As Exception MessageBox.Show(ex.Message.ToString) End Try End Sub
Add Routine: Add selected items from listbox1 to listbox2
Public Sub Add_ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add_ButtonX1.Click Select Case ListBoxControl1.Items.Count Case 0 MsgBox("There is nothing to add. Please browse for wav files.") Return End Select Try ' Add the paths to the wav files from listbox3 to listbox4 ListBoxControl4.Items.Add(ListBoxControl3.SelectedItem) ' Remove the selected items path from listbox3 ListBoxControl3.Items.Remove(ListBoxControl3.SelectedItem) ' Add the selected items from listbox1 to listbox2 ListBoxControl2.Items.Add(ListBoxControl1.SelectedItem) ' Remove the selected item from listbox1 ListBoxControl1.Items.Remove(ListBoxControl1.SelectedItem) ' Save the .wav items in listbox2 using the paths in listbox4 For list2 As Integer = 0 To Me.ListBoxControl2.Items.Count - 1 System.IO.File.Copy(ListBoxControl4.SelectedItems(list2), "C:\SFE\Temp\Sounds\" + (My.Computer.FileSystem.GetName(ListBoxControl4.Items(list2)))) Next Catch ex As Exception MsgBox(ex.Message) End Try End Sub
I have tried different ways without any luck.
Many Thanks to those who can help.