I want to get file path of a file that was modified within 7days after system date, without using for each. thank you!
Check with this line of code in An Assign Activity. This will return you a list of files in this type - List(Of FileInfo) - System.Collection.Generic.List(Of System.FileInfo)
Directory.GetFiles("yourDirectory").[Select](Function(f) New FileInfo(f)).Where(Function(f) f.LastWriteTime < DateTime.Now.AddDays(-7)).ToList()
Thanks for this, it works but I am getting this output.
“System.Collections.Generic.List`1[System.IO.FileInfo]”, I am trying to get the file path. thanks
Once you get list. Use for each and print item in write line. You will have your file name within the expected range.
I tried your suggestion but it runs through all 2000 files in the folder even if the modified date of the file is less than 7days. I wanted it to take only the file paths in the folder with the recent modified date without using for each to lessen the time. thank you
Let us know the date format of files.
date format is “mm-dd-yyyy”
Hi @Kelsey_Dane ,
Directory.GetFiles(“yourDirectory”).[Select](Function(f) New FileInfo(f)).Where(Function(f) f.LastWriteTime < CDate(DateTime.Now.AddDays(-7).ToString(“MM/dd/yyyy”))).ToList()
And then print the list count to check.
its still not working, maybe i missed something, i have attached here the sample sequence. thank you
getfilemodifiedrecently.xaml (11.3 KB)
It works for me.
I used :- Directory.GetFiles(“C:\Users\Jayesh\Desktop\Desktop Files”).[Select](Function(f) New FileInfo(f)).Where(Function(f) f.LastWriteTime < CDate(DateTime.Now.AddDays(-7).ToString(“MM/dd/yyyy”))).ToList()
Thanks! it finally worked! i happened to put in a type of array. I need to run this on 3000 folders, can you help how to set this up? thank you
Hi @Kelsey_Dane ,
can you please elaborate? this would read all the 3000 folders? directories? thanks
Oh, okay, then you have to use for each… it will generate list variables for you.
Thank you!! I’m now working on it! I just have to finalize everything, yay!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.