Opened/draft excel copies being pulled

Hi All,

I am trying to pull the excel with latest modified date and and it does work, but the issue is that, if there is any opened/draft copy with the latest modified date, that’s being pulled than the original file.

For Eg: in the below screenshot, it’s supposed to pull the last but one file, but its pulling the draft copy(last file). Any thoughts on how to pull only the actual files(not the opened ones)?

Hi @Krithi1 …You can try like this…

Directory.GetFiles("yourfolder_path","*.xlsx").OrderByDescending(Function(d) New FileInfo(d).LastWriteTime).Where(Function(n) not path.GetFileName(n).Contains("~$"))(0)

Note: Since I gave (0) at the end , you need to assign this to a string variable not string array…

1 Like

Thank you, it worked!

1 Like

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