![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Jan 2009
Posts: 3
Rep Power: 0
![]() |
Hi.
I am hoping someone here will be able to help me with this probelem? I have two listbox's on my form, listbox1 which displays a list of files that was found in a search and listbox2 which the user uses to add files from listbox1. What i am having problems with is that when the user selects an item from listbox1 to add it to listbox2 my program needs to be able to copy the selected file from it's current location to another folder on the hard drive. Below is part of the code i have at the moment. Browes Button:
Private Sub Browse_ButtonX2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Browse_ButtonX2.Click
ListBoxControl1.Items.Clear()
Select Case FolderBrowserDialog1.ShowDialog()
Case DialogResult.OK
Call FileTypeFinder(FolderBrowserDialog1.SelectedPath, ".wav")
End Select
End SubSearch Routine: Private 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))
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 SubAdd items from Listbox1 to Listbox2: (This is where i need to be able to copy the selected file from it's current location to another folder.) Private 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
For Each str As String In Me.ListBoxControl1.SelectedItems
Me.ListBoxControl2.Items.Add(str)
Next
For i As Integer = 0 To Me.ListBoxControl1.Items.Count - 1
If Me.ListBoxControl1.SelectedIndex = i Then Me.ListBoxControl1.Items.RemoveAt(i)
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End SubMany Thanks for any help. Worf |
|
|
|
|
|
#2 | |
|
hoßßy¦st C++ Þrogrammer
|
Re: File search results to listbox help.
Quote:
VB.NET Syntax (Toggle Plain Text)
|
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jan 2009
Posts: 3
Rep Power: 0
![]() |
Re: File search results to listbox help.
Hi cdingSpree
Thank you for your reply, before i can copy i need to be able to get the paths to each of the wav files in listbox1 and i am unable to work out how to do this. I forgot to mention that i am a newbie. Many Thanks |
|
|
|
|
|
#4 |
|
Newbie
Join Date: Jan 2009
Posts: 4
Rep Power: 0
![]() |
Re: File search results to listbox help.
you can search by doing this
Imports System.IO
listbox1.Items.AddRange(Directory.GetFiles("C:\", "*.wav", SearchOption.AllDirectories)) |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jan 2009
Posts: 3
Rep Power: 0
![]() |
Re: File search results to listbox help.
Thanks all Sorted.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to save all search engine results urls in a text file | abojan | ASP | 0 | Dec 27th, 2006 8:33 AM |
| Basic File Search Program | Twilight | C++ | 4 | May 18th, 2006 3:36 PM |
| Assist in using cdl to add long file name to listbox -VB6 | PrarieCat | Visual Basic | 0 | Jan 5th, 2006 4:54 PM |
| After execution - Error cannot locate /Skin File? | wchar | Visual Basic | 1 | Mar 5th, 2005 9:04 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |