Read foreach item that has not been read

hey guys i want to read each file that fits my category in a directory, but if there is a new file i dont want to read all of them again because there are another process that will take too much time.

i tried to save file i’ve read in an excel file, read it and check the directory if the new file is in the excel. if it doesn’t exist, it will write the excel file with the new list of files.

it worked, but the problem is read, it kept reading all my files(which fit the condition) in the directory. i use dtRead.ToString.Contains(Path.GetFileNameWithoutExtension(item.ToString)) = false in the condition

any help ?

image
image

conditioin : Path.GetExtension(item.ToString)=".xls" AND Path.GetFileNameWithoutExtension(item.ToString).StartsWith(“Network Attack Report”) AND IO.File.GetLastWriteTime(item.ToString).Month.ToString = timeNow.Month.ToString(“3”) AND IO.File.GetLastWriteTime(item.ToString).Year = timeNow.Year AND dtRead.ToString.Contains(Path.GetFileNameWithoutExtension(item.ToString)) = false

Hi @RobertoEwaldo

How about this solution. You first read all the files in the directory using Directory.Getfiles which is fine. In the For Each loop you have there, why not try to move the processed file to another folder may be a folder named like “Archive” or “Processed” using the Move File activity? This way, all the processed files will be removed from the directory and will be moved to another folder. And your Directory will be left with only the files that needs to be processed, and in each run, your application will consider only the files that needs to be processed. This way you also omit the filtering of files to find the files that needs to be processed which will be quite efficient.

I think this is the best and efficient solution to solve your problem easily…