Folder directory variable + latest file in it. after this rename?

hello guys, i need a variable that takes the directory along with the most recent file and rename

the most recent file variable is this one:
new DirectoryInfo(“name”).GetFiles().OrderByDescending(Function(f) f.LastWriteTime).First().ToString

however I need the full path of the directory + the most recent file, and then I’ll rename it, does anyone know how?

@Guilherme_Silva - Please try like this…

Directory.GetFiles("YourFolderpath").OrderBy(function(x) new fileinfo(x).LastWriteTime).First

Hope this helps…

1 Like

hello, thank you very much, it’s showing the oldest folder, i need the latest file, this file is excel csv, would i have to change something to pull this latest file ?

@Guilherme_Silva - Sorry My bad…

Just change it to OrderBydescending

  Directory.GetFiles("YourFolderpath").OrderBydescending(function(x) new fileinfo(x).LastWriteTime).First
1 Like

thank you very much indeed!!!

1 Like

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