multiple file search
-
have my program working but need to be able to search for files of multiple file types and search for multiple drives at the same time. Right now I can only search for one files type by typing the extension into a textbox. To search for the drive, i created a BrowseFolderDialog to search folder on a specific drive and the path is displayed in a textbox. So I have two question: Is there a way for me to search for multiple file types by typing the extensions in the textbox at the same time? Is there a way to search for more than one drive in a text box at one time? Here is some code: Private Sub GetDirectoryContents() Dim FilePattern As String = "*." & TextBox2.Text.Trim Dim sdir As String = TextBox1.Text.Trim Dim dDir As New DirectoryInfo(sdir) Dim fi As FileSystemInfo For Each fi In dDir.GetFileSystemInfos(FilePattern) ListBox1.Items.Add(fi.Name) Next End Sub This is the class I created to search for the folders: Dim MyBrowseFolder As New FolderBrowser() Public Function ShowDialog(ByVal browseFolderTitle As String) With MyBrowseFolder .Style = FolderBrowserStyles.BrowseForComputer .StartLocation = FolderBrowserFolder.MyComputer & .StartLocation = FolderBrowserFolder.MyDocuments 'Dialog box title .Description = browseFolderTitle .ShowDialog() 'Return the folder path. ShowDialog = .DirectoryPath jds1207
-
have my program working but need to be able to search for files of multiple file types and search for multiple drives at the same time. Right now I can only search for one files type by typing the extension into a textbox. To search for the drive, i created a BrowseFolderDialog to search folder on a specific drive and the path is displayed in a textbox. So I have two question: Is there a way for me to search for multiple file types by typing the extensions in the textbox at the same time? Is there a way to search for more than one drive in a text box at one time? Here is some code: Private Sub GetDirectoryContents() Dim FilePattern As String = "*." & TextBox2.Text.Trim Dim sdir As String = TextBox1.Text.Trim Dim dDir As New DirectoryInfo(sdir) Dim fi As FileSystemInfo For Each fi In dDir.GetFileSystemInfos(FilePattern) ListBox1.Items.Add(fi.Name) Next End Sub This is the class I created to search for the folders: Dim MyBrowseFolder As New FolderBrowser() Public Function ShowDialog(ByVal browseFolderTitle As String) With MyBrowseFolder .Style = FolderBrowserStyles.BrowseForComputer .StartLocation = FolderBrowserFolder.MyComputer & .StartLocation = FolderBrowserFolder.MyDocuments 'Dialog box title .Description = browseFolderTitle .ShowDialog() 'Return the folder path. ShowDialog = .DirectoryPath jds1207
let the users type multiple extensions to a textbox seperated by commas. create a thread to search a specific extension in your path and then run multiple instances of that thread with one extension in each thread. since you have the code convert the function you are using to a thread
Vilsad P P MCTS (Windows Applications) .Net 2.0
-
let the users type multiple extensions to a textbox seperated by commas. create a thread to search a specific extension in your path and then run multiple instances of that thread with one extension in each thread. since you have the code convert the function you are using to a thread
Vilsad P P MCTS (Windows Applications) .Net 2.0
-
http://www.codeproject.com/vb/net/threadingvbnet.asp[^]
Vilsad P P MCTS (Windows Applications) .Net 2.0
-
http://www.codeproject.com/vb/net/threadingvbnet.asp[^]
Vilsad P P MCTS (Windows Applications) .Net 2.0
-
Is this correct because its still not working? Dim MyThread As New System.Threading.Thread(AddressOf GetDirectoryContents) MyThread.Start() It may seem simple but I've never worked with threads before.
Threading is a advanced topic to understand in a few minuts. i thing you should search in MSDN and a overall knowledge about threads and threads in vb.net first. then write your program, thread functions are not like ordinary functions, and when handling you should be more cautious because you may end up in thread locks. but threads are good practice if you want your program run in a faster way (by deviding the work load to multiple threads so you can get all the work done simultaniously)
jds1207 wrote:
Dim MyThread As New System.Threading.Thread(AddressOf GetDirectoryContents) MyThread.Start()
there is no problem with your code, what is the error you are getting ?
Vilsad P P MCTS (Windows Applications) .Net 2.0
-
Threading is a advanced topic to understand in a few minuts. i thing you should search in MSDN and a overall knowledge about threads and threads in vb.net first. then write your program, thread functions are not like ordinary functions, and when handling you should be more cautious because you may end up in thread locks. but threads are good practice if you want your program run in a faster way (by deviding the work load to multiple threads so you can get all the work done simultaniously)
jds1207 wrote:
Dim MyThread As New System.Threading.Thread(AddressOf GetDirectoryContents) MyThread.Start()
there is no problem with your code, what is the error you are getting ?
Vilsad P P MCTS (Windows Applications) .Net 2.0
Error: Cross-thread operation not valid: Control 'ListBox1' accessed from a thread other than the thread it was created on. Right now, when I do the file search I type the file type in the textbox(txt) and the files with those types are displayed in a listbox. I want to change it so I can type in for example, txt, bmp, log into the textbox and display all of those file types in the listbox together. Is threading the only solution for this?
-
Error: Cross-thread operation not valid: Control 'ListBox1' accessed from a thread other than the thread it was created on. Right now, when I do the file search I type the file type in the textbox(txt) and the files with those types are displayed in a listbox. I want to change it so I can type in for example, txt, bmp, log into the textbox and display all of those file types in the listbox together. Is threading the only solution for this?
you can't directly use the objects you created in your application inside the thread, you can do your multiple extension search without a thread too, but you will have to search one by one extensions,but this will consume some time
Vilsad P P MCTS (Windows Applications) .Net 2.0