?
Solved

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

Posted on 2014-03-13
5
Medium Priority
?
318 Views
Last Modified: 2014-03-13
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 + "*");
0
Comment
Question by:Michael Sterling
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39927457
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
0
 
LVL 1

Author Comment

by:Michael Sterling
ID: 39927474
I have and neither seem to work. is there another function that i can use that will except 2 parameters?
0
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 2000 total points
ID: 39927488
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.
0
 
LVL 1

Author Closing Comment

by:Michael Sterling
ID: 39927594
Thanks for your help.
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39927628
Glad I could help!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question