jsctechy
asked on
how to search a file base on the name but not the extansion
hi,
this one is not too bad, I need to search for a file in a given directory without consider its extension. For instance i'm looking for a file called test and i need to search on directory C:\Temp\ but on that directory there are 4 files showing the word test like this:
Test.txt
Another_Test.doc
My_Test.pdf
Their_Test.mdb
so every file that match that keyword Test should be add it to my listbox1. How can i do my search?
Thanks for your input
jsctechy
this one is not too bad, I need to search for a file in a given directory without consider its extension. For instance i'm looking for a file called test and i need to search on directory C:\Temp\ but on that directory there are 4 files showing the word test like this:
Test.txt
Another_Test.doc
My_Test.pdf
Their_Test.mdb
so every file that match that keyword Test should be add it to my listbox1. How can i do my search?
Thanks for your input
jsctechy
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ipaulino,
you are close one thing though i dont need the whole path added to the listbox1. another thing it only display two files when there are 4 files with the search pattern
you are close one thing though i dont need the whole path added to the listbox1. another thing it only display two files when there are 4 files with the search pattern
ASKER
i need the path for later but no display it on the listbox1
Try this update
Dim path As String = "c:\temp\"
Dim searchPattern As String = "test"
Dim total As Integer = 0
Dim FileList() As String = IO.Directory.GetFiles(path, String.Concat("*", searchPattern, "*"))
For Each file As String In FileList
Dim fInfo As New FileInfo(file)
Me.ListBox1.Items.Add(fInfo.Name)
total += 1
If total >= 2 Then Exit For
Next
ASKER
ok that puts just the name of the file now i'm missing two files that have the same keyword
I have the following files:
01 this is a test.m4a
This is a test.m4a
New Text Documen testy.txt
test Microsoft Office Publisher Document.pub
but it only return the first two why?
i need everyfile that has the word test on it
I have the following files:
01 this is a test.m4a
This is a test.m4a
New Text Documen testy.txt
test Microsoft Office Publisher Document.pub
but it only return the first two why?
i need everyfile that has the word test on it
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You do not like the first post?
ASKER
i do but you did not included the result on the listbox while ipaulino did. thats all not hard feelings!!!!
ASKER
interested on more points?
https://www.experts-exchange.com/questions/23613979/how-to-create-a-checkbox-dinamically.html
Fernando you started thison the previous question i have =)
https://www.experts-exchange.com/questions/23613979/how-to-create-a-checkbox-dinamically.html
Fernando you started thison the previous question i have =)
Open in new window