How to sort a list of strings coming from Directory.GetFiles and store in a variable?

I’ve seen the other posts where the invoke activity is being used, the .Sort(), and the OrderBy method is being used, but I have ran into compiler errors.

This is how it’s setupt
attachmentFiles = Directory.GetFiles(file_path).Sort

I also tried
attachmentFiles = Array.Sort(Directory.GetFiles(file_path))

I also tried the invoke activity method as well with

Each of these has led to compiler errors. Is there a way to sort the array of strings grabbed from the Directory.GetFiles without errors?

welcome to the forum

First line is sorting on filename and returns an array (of FileInfo)

Second line shows on how to access the filepath info from a fileInfo

Hi @ppr ,

Thank you so much for your help. This was the correct solution and I was able to finally complete my project. You’re the best

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