Hi,
I have use case. I need to fetch the files in a folder upto last 5days Like last modified files
Please help me on this
Thanks in advance
Hi,
I have use case. I need to fetch the files in a folder upto last 5days Like last modified files
Please help me on this
Thanks in advance
Declare a string array and assign as below.
Including sub folders:
Directory.GetFiles(in_FolderPath,“.”,SearchOption.AllDirectories).Where(Function(x)CDate(new System.IO.FileInfo(x).CreatedDate)<Now.AddDays(-5)).ToArray
Only top directory:
Directory.GetFiles(in_FolderPath).Where(Function(x)CDate(new System.IO.FileInfo(x).CreatedDate)<Now.AddDays(-5)).ToArray
Hi @Krupa_P2
How about this expression?
Directory.GetFiles("",“.”,SearchOption.AllDirectories).Where(Function(x)CDate(new System.IO.FileInfo(x).LastModifiedDate)<=Now.AddDays(-5)).ToArray
Regards
Gokul
Hi,
You can sort files by creation time using this code:
Directory.GetFiles(“YourFolderPath”).OrderByDescending(Function(d) New FileInfo(d).CreationTime)
You can sort files by last write time using this code:
Directory.GetFiles(“YourFolderPath”).OrderByDescending(Function(d) New FileInfo(d).LastWriteTime)
And you can get 5 files using Skip method:
Directory.GetFiles(“YourFolderPath”).OrderByDescending(Function(d) New FileInfo(d).LastWriteTime).Skip(5).ToArray