While trying to implement Hadi's the solution to my question about import to SSIS the file with max filename in the folder, I encountered the following error:
Data Flow Task, Flat File Source [28]: Data conversion failed. The data conversion for column ""AsofDateTime"" returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.
Data Flow Task, Flat File Source [28]: The "Flat File Source.Outputs[Flat File Source Output].Columns["AsofDateTime"]" failed because truncation occurred, and the truncation row disposition on "Flat File Source.Outputs[Flat File Source Output].Columns["AsofDateTime"]" specifies failure on truncation. A truncation error occurred on the specified object of the specified component`
An error occurred while processing file "\Share\ABC_DE_FGHIJKL_MNO_PQRST_U-1234567.csv" on data row 387.
I spent hours on trying to find out what is specific about "row 387", playing this and that, removing and changing the source data, but did not get a hint at all - still the same error. SSIS package worked OK with explicitly specified filename, and the script correctly picks up the file with max filename but these parts simply do not work together, resulting in above error.