We have an input folder (C:\Test) contains files of various formats (.xslx, .docx, .zip, .tab).
Is there a way we can fetch the file name (only Name, do not require extension) which is having .tab extension?
(Please note - Inside that folder, there will be only single occurrence of that particular extension).
StrFileName = Path.GetFileNameWithoutExtension(Directory.GetFiles(YourFolderPath,“*.tab”).OrderByDescending(Function(d) New FileInfo(d).creationtime).First)
StrFile is of String Type
Since you already mentioned there will be only one occurence of that file, i have tried to extract the filename directly.
Sample Flow:
Input Folder (You can see I have only one exe file, and the above screenshot printed only filename without any extension)
Directory.GetFiles(YourPath, "*.tab").Select(Function (x) Path.GetFileNameWithoutExtension(x)).toarray
is retruning an array withg the filename(s) and can be defensively postprocess to get a/the filename