Search File inside a folder using wild card

katiefrog

New Member
I try to search a file using wild card.My code is:\[code\] string SearchQuery =''; List<ATTFile> lstFiles = new List<ATTFile>(); if (Directory.Exists(FilePath)) { DirectoryInfo dirInfo = new DirectoryInfo(FilePath);//File PAth is not a problem. foreach (FileInfo file in dirInfo.GetFiles(SearchQuery + "?"))//Want help here { ATTFile obj = new ATTFile(); obj.FileName = file.Name; obj.Folder = file.Directory.ToString(); obj.Size = int.Parse(file.Length.ToString()); obj.Extension = file.Extension; lstFiles.Add(obj); } }\[/code\]Code Works if I give full file name.For Example:Inside a directory I have following files.\[code\]and.jpgasp.jpgbb.jpgcc.jpg \[/code\]Using above code if I give full file name its work means \[code\]SearchQuery ="and.jpg"\[/code\].Its work.But If I give \[code\]SearchQuery ="a"\[/code\] I want a result\[code\]and.jpgasp.jpg\[/code\]Starts all files with \[code\]a\[/code\].Is it possible using wild card inside \[code\]GetFiles(SearchQuery + "?")\[/code\].Thanks.
 
Back
Top