By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,097 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,097 IT Pros & Developers. It's quick & easy.

Searching a directory for a file

P: 8
I'm trying to create a program so when you click a button there will be a search on the word typed into the text box and it will search in the selected drive. If you could tell me what that function or member is, or tell me how to do it, I would appreciate it.
Mar 22 '07 #1
Share this Question
Share on Google+
9 Replies


Expert 5K+
P: 8,434
I'm trying to create a program so when you click a button there will be a search on the word typed into the text box and it will search in the selected drive. If you could tell me what that function or member is, or tell me how to do it, I would appreciate it.
Which part are you seeking help with? We're here to help with specific problems, but you need to give it a shot and let us know which part of the code is giving you trouble.
Mar 23 '07 #2

P: 8
Which part are you seeking help with? We're here to help with specific problems, but you need to give it a shot and let us know which part of the code is giving you trouble.
Ok, what I have is, you can select the drive that you want, and I can get the "Search" button to read which directory I selected, but I want to know if there is actually a function or method for search, so it will search for what is entered in TextBox2 on the selected drive when the "search" button is clicked and display the results in a ListBox.
Mar 23 '07 #3

Expert 5K+
P: 8,434
Ok, what I have is, you can select the drive that you want, and I can get the "Search" button to read which directory I selected, but I want to know if there is actually a function or method for search, so it will search for what is entered in TextBox2 on the selected drive when the "search" button is clicked and display the results in a ListBox.
I don't think so. As far as I know, you'll have to (very carefully) open and read each file. Unless there's some sort of Google toolkit or something that you can invoke.
Mar 24 '07 #4

SammyB
Expert 100+
P: 807
Ok, what I have is, you can select the drive that you want, and I can get the "Search" button to read which directory I selected, but I want to know if there is actually a function or method for search, so it will search for what is entered in TextBox2 on the selected drive when the "search" button is clicked and display the results in a ListBox.
If you are using VB.NET, then you use Directory.GetFiles
See http://msdn2.microsoft.com/en-us/library/wz42302f.aspx.

If you are using VBA, then you use Dir or Application.FileSearch.

If you are using VB6, then if I remember you also use Dir.
Mar 24 '07 #5

Expert 5K+
P: 8,434
If you are using VB.NET, then you use Directory.GetFiles
If you are using VBA, then you use Dir or Application.FileSearch.
If you are using VB6, then if I remember you also use Dir.
I think the idea was to search within the files for a string.
Mar 25 '07 #6

P: 8
Well actually I have gotten my program to the point where it will attempt to search for the file I type into the textbox but the a security error comes up saying, access to ... is denied. I tried typing in "On Error Resume Next" but then nothing gets displayed at all, it just keeps on looping.
Mar 31 '07 #7

10K+
P: 13,264
Thread renamed .
Mar 31 '07 #8

Expert 5K+
P: 8,434
Well actually I have gotten my program to the point where it will attempt to search for the file I type into the textbox but the a security error comes up saying, access to ... is denied. I tried typing in "On Error Resume Next" but then nothing gets displayed at all, it just keeps on looping.
Are you trying to open the files, or just find them by name?
Mar 31 '07 #9

P: 8
Are you trying to open the files, or just find them by name?
Well for now im trying to be able to pick a directory and then search for a file within it and eventually i will want to be able to open it and run it.
Jun 1 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.