I am trying to sort the following files in this order:
TMP_SDF_1180741.PDF
TMP_SDF_1179715.PDF
TMP_SDF_1162371.PDF
TMP_SDF_1141511.PDF
TMP_SDF_1131750.PDF
TMP_SDF_1117362.PDF
TMP_SDF_1104199.PDF
TMP_SDF_1082698.PDF
TMP_SDF_1062921.PDF
TMP_SDF_1043875.PDF
TMP_SDF_991514.PDF
TMP_SDF_970621.PDF
TMP_SDF_963154.PDF
TMP_SDF_952954.PDF
TMP_SDF_948067.PDF
TMP_SDF_917669.PDF
TMP_SDF_904315.PDF
TMP_SDF_899902.PDF
TMP_SDF_892398.PDF
TMP_SDF_882024.PDF
But the actual output is this:
TMP_SDF_991514.PDF
TMP_SDF_970621.PDF
TMP_SDF_963154.PDF
TMP_SDF_952954.PDF
TMP_SDF_948067.PDF
TMP_SDF_917669.PDF
TMP_SDF_904315.PDF
TMP_SDF_899902.PDF
TMP_SDF_892398.PDF
TMP_SDF_882024.PDF
TMP_SDF_1180741.PDF
TMP_SDF_1179715.PDF
TMP_SDF_1162371.PDF
TMP_SDF_1141511.PDF
TMP_SDF_1131750.PDF
TMP_SDF_1117362.PDF
TMP_SDF_1104199.PDF
TMP_SDF_1082698.PDF
TMP_SDF_1062921.PDF
TMP_SDF_1043875.PDF
I have tried researching sort methods by GetFiles but when I apply them, i get errors about system collections not able to bind to a 1-dimensional array and it is frustrating. Here is my code:
Dim di As New IO.DirectoryInfo("C:\temp")
Dim aryFi As IO.FileInfo() = di.GetFiles("*.PDF")
Dim fi As IO.FileInfo
For Each fi In aryFi
My.Computer.FileSystem.RenameFile("C:\TEMP\" & fi.Name, listBox1.SelectedItem.ToString & ".pdf")
listBox1.SelectedIndex = listBox1.SelectedIndex - 1
Next
I am renaming files to be a1 a2 a3 etc so that when I combine in PDF, they are in chronological order. The way i want the sorting, will place them in chronological order. I am sure there is an easier way. As you can tell, the higher the number in the PDF file (1180741) the most recent date of the content of the file. While 882024 would be the oldest file content.