Hi Devs,
I want to search any specific file in last 15 days folder until file not found.
Below is the scenario:
29—file not found
28—file not found
27—file not found
26—file not found
…
…
14—file not found
13–file found–exit from loop—read that file
12
11
filePath = (From day In Enumerable.Range(0, 15)
Let folderDate = DateTime.Now.AddDays(-day).ToString("dd-MM")
Let folderPath = Path.Combine(baseFolderPath, folderDate)
Where Directory.Exists(folderPath)
Let files = Directory.GetFiles(folderPath, fileName)
Where files.Length > 0
Select files.FirstOrDefault()).FirstOrDefault()
Use For Each Folder in Folder activity to iterate through the folders.
Use IF activity with below condition expression: Not Directory.GetLastWriteTime(CurrentFolder.FullName) >= DateTime.Now.AddDays(-15)
If True: Use Continue activity to move to check next folder ELSE: Move further to check files inside the folder.
Use For Each File in Folder activity to iterate through the files from the current folder.
Use IF activity to check the current file name in the folder is matching with your file name or not (I’m using Variable named as FileName in sequence)
If File Name matched then you can use Read File activity according to the File Type.