i used this : String.Join(“”, Directory.GetFiles(ExcelFile1,”*”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).LastWriteTime).Take(1))
But i have an oder folder inside the first one and i have new files into it. The bot doesnt stop to the first folder it takes the last file into the second folder, is it normal with this sentence ?
i want that the bot takes the last file in the first folder
In the below screenshot , I have lot of folders inside the folder “Studio” if i want to pick the “Misc xaml” folder then I have to go with LastWritetime…And then read the “Misc Xaml” folder to check last file
Like this…what is the first condition to choose from the list of folders??
Still I do not understand. But just remove this option and try. Above option will search for all the subfolders so if you do not want that, just remove and give it a try.
Ok just to be clear, if i take your screen you have the folder Studio its the equal of my folder 1 and you have the folder Misc xaml its the equal of my folder 2.
So i have files in Studio folder and files in Misc folder, with my sentence the bot takes the last file in Misc Folder not in Studio Folder. What i need is it takes the last file in Studio Folder
@Soudios … StrRecentFile and StrOlderFile is String Variables…
StrRecentFile=Directory.GetFiles(ExcelFile1).OrderBydescending(Function(d) New FileInfo(d).LastWriteTime).First
StrOlderFile=Directory.GetFiles(ExcelFile1).OrderBy(Function(d) New FileInfo(d).LastWriteTime).First
In my sentence i put the link here :
String.Join(“”, Directory.GetFiles(LINK,”*”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).LastWriteTime).Take(1))
I gave the perfectly working code…I am not sure why are going back with your old code which is having “SearchOption.AllDirectories”…I already told that, if you add this code, bot will look for all the subfolders…that’s why in my code I have removed it…
I am not sure, what exactly you are trying to acheive with String.join. String.Join will help if you have to multiple strings. In your code, since you gave take(1), there will be only one string output.