I am trying to get all files from a folder using GetFiles (path) and sort them by date/time.
New files are added in the folder and I am trying to extract the latest one.
Right now they are sorted alphabetically. Any ideas for the easiest way to do this?
Should be simple but I can’t figure it out.
There might be an easier way to do this, but this is how I managed to get to it:
First add mscorlib as a dependency:
Then, navigate to the File class in the Node Browser:
And there, you should see the GetCreationTime and GetLastAccessTime nodes which will take in the string path for the file you want to check, and return the time value.
@ravazquez thanks a lot for your help and the detailed explanation.
I can see the GetCreationTime and GetLastAccess time and indeed I can now get the time value.
I assume now I have to somehow compare all the time values for all the files and see which one is the earliest. Any idea how to do this? I am still trying to wrap around my head how to use Loops.
Btw I am sure there must be an easier way… seems like we are re-inventing the wheel.
just return the creation date as order key. the region basically asks you for every element what the order should be based on. so in this case the creation time, so connect that to the Result pin inside the region.