I have a list file in a folder like the below image, i usually loop the files in a folder like this
Directory.GetFiles(folderLocation,“.”) , then set it to a variable with type array of object . But I want to have the oldest file to loop first i, scenario is work with oldest file to newest file. I seen many examples of getfiles.orderbyascend etc, none are working, how can I achieve this?
Hi @Jay_Chacko … are you choosing oldest by “Date Modified”??
i would say so, or “created at” probably fine since the file don’t get edited after creation
@Jay_Chacko - Please check this post…
You just have to tweek the LINQ query posted there…Hope this helps…
if you are still having issues, let me know i will try to share the sample
i keep getting datatype error, attempting to use this code, my variable is a datatype System.object , always used this for looping files but first time using like this
Directory.GetFiles(sourceFolder,“.”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Last
@Jay_Chacko - Here you go…
XAML :

Directory.GetFiles(“YourFolderPath”).OrderBy(Function(d) New FileInfo(d).creationtime)
StrFiles =
For Each : argument type is Object
Write Line: Path.GetFileNameWithoutExtension(EachFile.ToString) + " creation time is " + File.GetCreationTime(EachFile.ToString).ToString
Output:
what is datatype of StrFiles? was kind of hard to see, i guessed some and was giving me error
Hi @Jay_Chacko - I have provided the screenshot for that above…