Click here to Skip to main content
15,893,923 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey All,

I am writing a anti-malware package in c# and one of the features I would like to add to the application is that as soon as a download begins then the application would detect it and compare it to known corrupt files. Is this even possible?

What I have tried:

I have tried to have it run as a service but the application doesn't react to downloads.
Posted
Updated 3-Sep-16 13:07pm
Comments
Philippe Mori 27-Aug-16 13:57pm    
Windows already do something similar by warning us when we download uncommon EXE files.

In my opinion, C# is not adequate for that purpose. Any background process that would do some scanning should probably written in native code to have minimal impact on the supervised system.

Also it is somewhat futile to do that... Either you need quite a big infrastucture and popularity to make useful or it would be almost useless as there are millions of possible downloads.

Simple comparison is probably not adequate as software is often updated so it would be hard to keep up to date.

1 solution

You can use the file system watcher class in C# to detect new file downloads.

FileSystemWatcher Class (System.IO)[^]

With the following events, you can do anything you need when a file is altered/updated/deleted.

C#
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.Created += new FileSystemEventHandler(OnChanged);
watcher.Deleted += new FileSystemEventHandler(OnChanged);
watcher.Renamed += new RenamedEventHandler(OnRenamed);


Keep in mind this would have to be implemented as a windows service to continuously monitor a directory.

The link i provided provides samples for what you need to do to make FileSystemWatcher class work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900