I am using the following code to get the latest file from a folder. Now, my requirement is to get the oldest file from the list, instead of the latest one. I don’t see the OrderByAscending function to use. Can someone help please?
Directory.GetFiles(“Path”,“ORCH"+".xlsx”).OrderByDescending(Function(d) New FileInfo(d).LastWriteTime).Where(Function(n) not path.GetFileName(n).Contains(“~$”))(0)
Just use OrderBy, it will order in ascending order
Directory.GetFiles("Path","ORCH"+".xlsx”).OrderBy(Function (d) New FileInfo(d).LastWriteTime).Where(Function (n) Not Path.GetFileName(n).Contains("~$")).First