I currently have a variable that I am using the ‘get file path without extension’ on. The excel file end in date format i.e. 10.30.25. Because of the nature of the get file path without extension method the ‘25’ at the end of the file name is getting cut off and my process is unable to find the matching folder. Are there any alternative methods that can be used to parse the file name out of the path.
If you are sure about the file extension going to be .xlsx then you can remove the last 5 characters using this code.
yourString.Substring(0, yourString.Length - 5)
You can try Capture everything before a known Excel extension using regex
Like this: ^(?i)(.*?)(?:.xlsx|.xlsm|.xls|.csv)$
@ashokkarale @Gabriel_Moreno2
A few details I left out that might be important. I first have a variable with the folder path i.e. ‘folder1/folder2/file name 10.1.25 - 10.30.25’
It doesn’t show the fie type in the folder path, but maybe I need to use a regex match to parse this out.
Not sure how you have the file path without file extension but then you should be able to get the file name using this:
Path.GetFileName(yourPathVariable)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.