I have files as follows in a directory.
1-abc.pdf
17 - xyz.pdf
18 -fdf.pdf
1 - fff.pdf
1 -tyty.pdf
and i need to get the files that starts with “1-” or "1 - "or “1 -”
When i am using directory.getfiles(Path,“1*.pdf”) i am getting all the files including 17 and 18.
I just need the files that start with 1 followed by - or file that start with 1 followed by space and -.
So in this case i just need the files
1-abc.pdf
1 - fff.pdf
1 -tyty.pdf
Please help
@Yoichi and @aanandsanraj it is not working because the folder name that is used by the files also has 1-.and hence it is returning all the files
Example:
C:\Test*1-Client Documents*\1-abc.pdf
C:\Test*1-Client Documents*\17 - xyz.pdf
C:\Test*1-Client Documents*\18 -fdf.pdf
C:\Test\1-Client Documents\1 - fff.pdf
C:\Test\1-Client Documents\1 -tyty.pdf
Any idea how we can solve this?
@Palaniyappan that code did not work, but the following worked
string variable item =“1”
strItem=item+“*.pdf"
list = Directory.GetFiles(in_DocumentPath,strItem).Where(function(x) System.Text.RegularExpressions.Regex.IsMatch(x,“\”+item+"(?=\D)(?:[^\\n.].)?[^.\\n]+.pdf$”)).ToList