Value of type 'System.Linq.IOrderedEnumerable(Of String)' cannot be converted to ''1-dimensional array of String

Hi,

Trying to get all xml files in a directory but need to get the oldest first.

String[]=Directory.GetFiles(in_Config(“FolderPath”).ToString,“*.XML”, SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime)

Trying several ways, but ending up getting

Value of type ‘System.Linq.IOrderedEnumerable(Of String)’ cannot be converted to ''1-dimensional array of String.

Hi,

Can you try to add .ToArray() at the end of the expression as the following?

String[]=Directory.GetFiles(in_Config(“FolderPath”).ToString,"*.XML", SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).ToArray()

Regards,

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