Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,
I want to search files which has Extension .JPG but name must start with textbox.text * .JPG.
Actually file name format is:P12345_1.JPG,P12345_2.JPG and so on..So how to use search criteria for this?
Please reply me.Its urgent.
Posted
Comments
Ashwani Gusain 22-Oct-13 0:40am    
from text box u want search or in other way.Can u explain from where u want to search?
Member 10315373 22-Oct-13 0:55am    
Actually Filename start from P12345_1.JPG,P12345_2.JPG ok.this P12345 is pass from textbox then How I do search criteria for this?B'cos *.JPG searches all files Of extension .JPG but I want only which are start from P12345 and with extension .JPG
So what I do?
Member 10315373 22-Oct-13 1:01am    
Probem get solved thanks for comment

1 solution

Use Directory.EnumerateFiles[^] to find a list of files matching a certain character expression.
Building the search pattern in your case should be straigh-forward.
 
Share this answer
 
Comments
Thanks7872 22-Oct-13 0:55am    
:thumbsup:
Member 10315373 22-Oct-13 0:56am    
It also not work for me..My question is:
Filename start from P12345_1.JPG,P12345_2.JPG ok.this P12345 is pass from textbox then How I do search criteria for this?B'cos *.JPG searches all files Of extension .JPG but I want only which are start from P12345 and with extension .JPG
So what I do?
Member 10315373 22-Oct-13 1:01am    
Thanks for Comment.Problem get solved.
Thanks7872 22-Oct-13 1:09am    
Its always a good practice to post the solution which worked for you. It helps some one who face similar problem.
Member 10315373 22-Oct-13 6:06am    
Answer Is: FileInfo[] files = dir.GetFiles("" + Drp_pnlnumber.Text + "*.JPG");
where Drp_pnlnumber is your starting matching string and * is for further string.

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