Hi All, I have the SSIS package to extract the data from txt file. One of the task in my SSIS is using script task to get filedate,filename and etc. Previously I have a filename like below in Example 1. Hence, I use below shared C# script to get the date from the filename. If the filename got changes like below in Example 2, how can I do changes in the C# script to get the date from filename? Kindly please help.
string FileName = System.IO.Path.GetFileName(Dts.Variables["User::v_FILEPATH"].Value.ToString());
Dts.Variables["User::v_FILENAME"].Value = FileName;
string FilenameWoutExt = System.IO.Path.GetFileNameWithoutExtension(Dts.Variables["User::v_FILENAME"].Value.ToString());
string dateValue = FilenameWoutExt.Substring(FilenameWoutExt.LastIndexOf('_')+1);
Dts.Variables["User::v_FILEDATE"].Value = dateValue;