Error Cannot assign System.IO.FileInfo to System.String[]

I am trying to get latest excel files from a folder, and iterate those to write some text.

There are several files with the same modified date and time.
That is why I want to pull files as list type.

I use this Directory.GetFiles("Path")).Select(Function(f) New FileInfo(f)).OrderByDescending(Function(b) b.LastWriteTime).ToList(0).ToString to get the latest files.
However when I assign a variable with above, I get an error:

How do I fix this?

@yesterday …tolist(0) will give you only one file output which is a string.

So if you want multiple files then just use .Tolist

Thank you for your reply.

That’s good to know.

I still get an error.
Do you know how to fix this?

@yesterday - please share the code which you are using and let us know your requirement clearly.

It should not end with .tostring

  1. I want to get a list of excel files with the latest modified date from a certain folder.
    I get the error here.
    Assign activity:
    str[] files = Directory.GetFiles("Path")).Select(Function(f) New FileInfo(f)).OrderByDescending(Function(b) b.LastWriteTime).ToList.ToString

  2. I want to iterate the list using for each to write some text in a cell to each file.

@yesterday - Correct Code should be like this…this will sort all the files in the folder based on last write time

str[] files = Directory.GetFiles("FolderPath").OrderByDescending(Function(f) New FileInfo(f).LastWriteTime).Toarray

If you want get the files with modified date today…

str[] files = Directory.GetFiles("FolderPath").where(function(x) new fileinfo(x) =

If you want get the files with modified date today and orderbyDesending…

str[] files= Directory.GetFiles("FolderPath").where(function(x) new fileinfo(x) = new fileinfo(f).LastWriteTime).ToArray

Hope this helps…

Thank you so much for your answer.
I will update this post when i get to work on the project. I havent started it yet.

Thank you,