I am working on an interesting problem wherein i have to attach one file from my local system to a web based ui.
But the issue is that the file to be attached should be the latest file from the local directory.
Now the directory structure of my local where the files reside is as follows:-
1.1 Green_Folder( Containing green.xlsx - Date modified 12:30pm)
1.2 Red_Folder( Containing red.xlsx Date modified 12:29)
So the output i am expecting is that since the Green_Folder has the latest file, in my workflow the Green Folder should open up and i shall then use a click activity to attach the Green File.
I think there is no efficient way to solve this but some workaround would be to get the latest file from both of the directories, compare their modification dates using the IF statement, and get the latest one from those two.
Here is some help on how to get the latest file from the directory:
I need to get latest text file from folder how to do that please some one help me
Hope that help.
@shekhawat.arjun1307 If you want to get the last modified file from a list of many folders, then according to your inputs you should be able to get the Last Modified file using the below expression :
lastModifiedFile = Directory.GetFiles("Output","*.xlsx",SearchOption.AllDirectories).OrderByDescending(Function(x)new FileInfo(x).LastModifiedDate).First
Where “Output” is the Parent Folder which contains many sub folders to search for the last modified file.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.