Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!

I need to search for a file, in a directory, but the files names are like: 123456_otherthings.
I only know the 123456 part of the string. My question is, How can I find the file witch contains 123456?

I am looking forward to your answers.
Posted

you can use this. it will return new list which contains your parameter
C#
string[] files = Directory.GetFiles(your_file_path);
List<string> _files = files.ToList<string>();

 _files = _files.FindAll(delegate(string s)
{
        return s.Contains(your_search_parameter);
 });</string></string>
 
Share this answer
 
These might help:
How to find the file by its partial name?[^]
IN c# how to get file names starting with a prefix from resource folder[^]

I found them on Google - find file name starts with c#[^]. Google also helped me by suggesting search query while I was typing find by file name c#.

Please do search before you ask.
 
Share this answer
 
Comments
kirk651 17-Feb-14 4:20am    
Many thx!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900