I am trying to find files using their ID but the filename has yyyymmdd append on the end. The pattern of the filename is not uniform as well. I initially used the Directory.GetFiles( location ,""+ id +"", SearchOption.AllDirectories) but I’m afraid that the id may also match the date at the end of the filename. I only want the files that match the id once. I used matches but it doesn’t work. Any idea? Thanks!
we can get the files with the fileextension like this either .pdf, .xlsx, or .xls, .doc
hope this would help you
kindly correct me if i m wrong with the question
hi @Palaniyappan I’m not looking for fileextension. I want to get only the files that match the filename.
Example this is the files:
My index is the ID which is 123 or 170. I only want to get the one that matched once. So in the example above, if I used the ID as index, I should only get the file with 123 ID since it only matched the filename once. While the file with 170, matched twice since there is also 170 on the date at the end of filename.
I use wildcard for both since I do not know where the ID will be on the filename. It may be at the start or in the middle. As I say before, the filename is not uniform
use the below expression that will return you the latest file based on the pattern you passed inside the expression
filename =String.Join("",Directory.GetFiles(FolderName,“Patternofthefilename*.Extentsion”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1) )
this expression will return the file name based on the create time of the file.
Hello @Ajju Sorry that’s not what I’m looking for
Is there a resolution for this ?