[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2014-03-13
5
Medium Priority
?
320 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

649 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