Regex to append a timestamp to a string name before extension

String = “Filename1.xls”
timestamp I wanted to append i (DateTime.Now.ToString(“yyyy-MM-dd_HH-mm-ss”)

Output that I want to achieved is = “Filename1-2020-10-12_07-38-32.xls”

Any idea with this one guys ? Thanks

Hi,

Can you try the following?

System.IO.Path.GetFileNameWithoutExtension(filename)+now.toString("-yyyy-MM-dd_HH-mm-ss")+System.IO.Path.GetExtension(filename)

Regards,

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.