There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
black screen blue screen boot bsod computer connection crash css dell display driver drivers email error firefox firefox 3 freeze game hard drive internet internet explorer itunes laptop lcd linux malware monitor network networking nvidia outlook outlook 2003 outlook express partition password printer problem router slow sound sprtcmd.exe startup trojan usb video virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Wildcard file search inVB6


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
asbo's Avatar
Senior Member with 510 posts.
 
Join Date: Sep 2001
Location: who really knows anymore?
Experience: Advanced
26-Dec-2003, 03:53 PM #1
Wildcard file search inVB6
hey --

I'm trying to get all of the files in directory 'X' with the extension 'Y', and then have the names of those file available for manipulation, maybe in a string array? Can someone help me? I've looked at the documentation for the FSO, but couldn't pick anything out of it.

http://msdn.microsoft.com/library/de...asp?frame=true


Thanks,
asbo
__________________
·· ħþø ··
-----
- User Friendly by Illiad -
MustBNuts's Avatar
Senior Member with 1,930 posts.
 
Join Date: Aug 2003
Location: Nevada
27-Dec-2003, 02:34 PM #2
Your question seems a bit broad. There are many steps in the process you've described. What part of it are you getting hung up with?

MBN
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
29-Dec-2003, 08:09 PM #3
Did you want to get the files in the top of the directory only Or were you trying to recursively search all the subdirectories......to the end?
asbo's Avatar
Senior Member with 510 posts.
 
Join Date: Sep 2001
Location: who really knows anymore?
Experience: Advanced
30-Dec-2003, 10:54 AM #4
hey --

Sorrry, I'm trying to get the files in the top directory, not any of the subdiectories.

The part that I'm not getting is how one might go about searching a directory with a wildcard, or at all...



asbo
coderitr's Avatar
Distinguished Member with 3,080 posts.
 
Join Date: Oct 2003
30-Dec-2003, 12:08 PM #5
You can use a file list box to enumerate the files in a given directory. The control contains path and pattern properties that when set, automatically load the list of files. You can also set the sort property to have the list sorted automatically. You can always have the control moved past the visible dimensions of your form or just set the visible property to false if you don't want the user to see it.

If you don't want the overhead of the file list box, check out the Win32FindFirstFile( ) and Win32FindNextFile( ) in the Win32 API.
Mosaic1's Avatar
Distinguished Member with 7,502 posts.
 
Join Date: Aug 2001
30-Dec-2003, 07:23 PM #6
This will create an array of the filenames and show in a multilined text box with a scrollbar. I also added the index to the array for each item. You could use the List is you like. The textbox is there for you to check your work. It depends on what you want to do.

Code:
Private Sub Command1_Click()
Dim i As Integer, sfile$, arrFiles() As String
sfile = Dir("C:\Windows\*.txt")
Do Until sfile = ""
ReDim Preserve arrFiles(i)
arrFiles(i) = sfile
i = i + 1
sfile = Dir
Loop

For i = LBound(arrFiles) To UBound(arrFiles)
msg = msg & i & " " & arrFiles(i) & vbCrLf
Next
Text1 = msg

End Sub
asbo's Avatar
Senior Member with 510 posts.
 
Join Date: Sep 2001
Location: who really knows anymore?
Experience: Advanced
30-Dec-2003, 10:53 PM #7
hey --

Thanks for the help I'll test both out and see which fits what I'm trying to do.

Thanks again!
asbo

Last edited by asbo : 30-Dec-2003 11:17 PM.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:08 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.