Check if there is file with todays date

Hi,
I have a folder with excel files created every day and I have to check if there is file from today, if not, then send mail. Files are recognised by name containing “DS”. Tried with flagBool = True but not working, it is always showing that it is false.

You need to provide more info, like what the filenames look like.

Hi @markosc

What was the date format in the file be like…

thanks

first assign variable with date and put as now.date
use activity path exists and select as file category
in filename section, pass it as “your filename”+ datevariable
if it returns true, your file exists else your file not exists

Here is an example of a folder. I have to check if there is file with date modified equal to now.date, if there is not, send an email.

the dates are of course different (made every day) this is just an example

Hi @markosc

Can we check the date modified and based on that decide whether it is created today or not

Thank you,
Prashant

I need to check if there exists a file with date modified = today

@markosc - please check this post

This has the code you are looking for.

And how do I then chek if there is not - send mail?

Hi @markosc
Modifying @prasath17 code a little to get it matched for your case

Directory.GetFiles(“C:\Users\giris\Desktop”).Where(Function(x) New FileInfo(x).LastWriteTime.Date = DateTime.Today.Date and Path.GetFileName(x).Contains(“DS”)).Count>0 use this as if condition to check if there are files as per your criteria or not

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.