Minifilter - Scan any files added to your pc

I am making a program that basically scans any new files downloaded to my PC. I just want to scan only after the file is completely downloaded to the PC. I have gone through the Avscan minifilter examples but it scans any file opened. So even if a file is downloading, it scans while downloading as well because chrome/firefox opens the file for modification while downloading. So how can scan just after the file is completely downloaded.

What I have tried so far -
I have used a file watcher to detect any new files.
Whenever a file is downloaded from chrome then the following happens :

For example: Let’s say a pdf file is being downloaded.

  • .tmp file created first

  • .tmp file is renamed to .crdownload

  • .crdownload is modified multiple times

  • .crdownload file is renamed to .pdf

  • .pdf file is modified multiple times.

The problem is when can I say a file is completely downloaded because it is modified multiple times after renaming from .crdownload to .pdf file.

Once become sure that the file is completely downloaded then we can scan the file.
So how can we be sure that file is completely downloaded?
After that, if anyone opens the file then we can use Avscan to scan the data in the file.

Any help I am looking for from the great community.
Thanks a lot.

“Oh, and by the way… I’m doing this as a personal learning exercise. I don’t actually have a professional work need to do this.”

@“Peter_Viscarola_(OSR)” Can you please help me out?