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:

but this isn't working. any suggestions?

string[] sFiles;
sFiles = Directory.GetFiles(myGlobalVars.gsDirectory.ToString(), "*." + sLoopExt + "*");
Michael SterlingWeb Applications DeveloperAsked:
Who is Participating?
Dan CraciunConnect With a Mentor IT ConsultantCommented:
OK, can you output
myGlobalVars.gsDirectory.ToString() + "*." + sLoopExt + "*"
Just to see if the path string is constructed properly.

dir x:\path\*.gl* does work in command prompt, so it should work here too, if the path is correct.
Dan CraciunIT ConsultantCommented:
Have you tried
sFiles = Directory.GetFiles(myGlobalVars.gsDirectory.ToString() + "*." + sLoopExt + "*");

Open in new window

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.

Michael SterlingWeb Applications DeveloperAuthor Commented:
I have and neither seem to work. is there another function that i can use that will except 2 parameters?
Michael SterlingWeb Applications DeveloperAuthor Commented:
Thanks for your help.
Dan CraciunIT ConsultantCommented:
Glad I could help!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.