Link to home
Start Free TrialLog in
Avatar of Michael Sterling
Michael SterlingFlag for United States of America

asked on

How do I construct my search pattern with multiple wild cards?

I'm trying to pull files from a directory into a string array. I need to match the pattern for something like this:

"*." + file extension + "*"

so i can pick up files that match this pattern:

filename1.gl
filename1.gl1

but this isn't working. any suggestions?

string[] sFiles;
sFiles = Directory.GetFiles(myGlobalVars.gsDirectory.ToString(), "*." + sLoopExt + "*");
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Have you tried
sFiles = Directory.GetFiles(myGlobalVars.gsDirectory.ToString() + "*." + sLoopExt + "*");

Open in new window

or
sFiles = Directory.GetFiles(myGlobalVars.gsDirectory.ToString(), "\*." + sLoopExt + "*");

Open in new window

depending on if gsDirectory includes the final "\" or not

Get files only accepts one parameter, the path, AFAIK.

HTH,
Dan
Avatar of Michael Sterling

ASKER

I have and neither seem to work. is there another function that i can use that will except 2 parameters?
ASKER CERTIFIED SOLUTION
Avatar of Dan Craciun
Dan Craciun
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help.
Glad I could help!