Question
Tech Mahindra Ltd
Tech Mahindra Ltd
BE
Tech Mahindra Ltd
Posted: Jul 10, 2019
Last activity: Jul 10, 2019
Last activity: 10 Jul 2019 5:30 EDT
Closed
Pega RPA : how to fetch last modified file in a directory
I have a scenario where i need to fetch the last modified file in a directory. Can someone help me to find the component to achieve this..
Use C# code as below
string path = @"Folder Path";
DirectoryInfo di = new DirectoryInfo(path);
FileInfo[] fiArray = di.GetFiles();
Array.Sort(fiArray, (x , y) => StringComparer.OrdinalIgnoreCase.Compare(x.LastWriteTime, y.LastWriteTime));
string LatestFile = fiArray[fiArray.Length-1].ToString();