Click here to Skip to main content
14,302,627 members
Rate this:
Please Sign up or sign in to vote.
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
Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
   
Comments
kirk651 17-Feb-14 4:20am
   
Many thx!
Rate this:
Please Sign up or sign in to vote.

Solution 2

you can use this. it will return new list which contains your parameter
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>
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100